The solution has been found! Look at the post
It was necessary to create a service account, configure the correct permissions for it
The final configuration that works for me
apiVersion: beat.k8s.elastic.co/v1beta1
kind: Beat
metadata:
name: eck-filebeat
namespace: eck
spec:
[...]
config:
filebeat.inputs:
# Ingress-nginx block
- type: container
paths:
- /var/log/containers/*ingress-nginx*.log
processors:
- add_kubernetes_metadata:
host: ${NODE_NAME}
matchers:
- logs_path:
logs_path: "/var/log/containers/"
# Java apps block
- type: container
paths:
- /var/log/containers/*mp-dev*.log
- /var/log/containers/*mp-rc*.log
[...]
processors:
- add_kubernetes_metadata:
host: ${NODE_NAME}
matchers:
- logs_path:
logs_path: "/var/log/containers/"
[...]
daemonSet:
podTemplate:
spec:
serviceAccount: elastic-beat-filebeat
automountServiceAccountToken: true
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: false
securityContext:
runAsUser: 0
containers:
- name: filebeat
volumeMounts:
- name: varlogcontainers
mountPath: /var/log/containers
- name: varlogpods
mountPath: /var/log/pods
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumes:
- name: varlogcontainers
hostPath:
path: /var/log/containers
- name: varlogpods
hostPath:
path: /var/log/pods
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
tolerations:
- key: "type"
operator: "Equal"
value: "monitoring"
effect: "NoSchedule"
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: elastic-beat-filebeat
namespace: eck
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: elastic-beat-autodiscover-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: elastic-beat-autodiscover
subjects:
- kind: ServiceAccount
name: elastic-beat-filebeat
namespace: eck
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: elastic-beat-autodiscover
rules:
- apiGroups:
- ""
- apps
- batch
resources:
- nodes
- namespaces
- events
- pods
- replicasets
- jobs
verbs:
- get
- list
- watch