Last active
March 3, 2023 22:15
-
-
Save exekias/f8b0b300966fa148ac239ffaa70b5721 to your computer and use it in GitHub Desktop.
Example of autodiscover usage in filebeat-kubernetes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: filebeat-config | |
namespace: kube-system | |
labels: | |
k8s-app: filebeat | |
kubernetes.io/cluster-service: "true" | |
data: | |
filebeat.yml: |- | |
filebeat.autodiscover: | |
providers: | |
- type: kubernetes | |
templates: | |
- condition: | |
equals: kubernetes.namespace: development | |
config: | |
- type: docker | |
containers.ids: | |
- "${data.kubernetes.container.id}" | |
processors: | |
- add_cloud_metadata: | |
cloud.id: ${ELASTIC_CLOUD_ID} | |
cloud.auth: ${ELASTIC_CLOUD_AUTH} | |
output.elasticsearch: | |
hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}'] | |
username: ${ELASTICSEARCH_USERNAME} | |
password: ${ELASTICSEARCH_PASSWORD} | |
--- | |
apiVersion: extensions/v1beta1 | |
kind: DaemonSet | |
metadata: | |
name: filebeat | |
namespace: kube-system | |
labels: | |
k8s-app: filebeat | |
kubernetes.io/cluster-service: "true" | |
spec: | |
template: | |
metadata: | |
labels: | |
k8s-app: filebeat | |
kubernetes.io/cluster-service: "true" | |
spec: | |
serviceAccountName: filebeat | |
terminationGracePeriodSeconds: 30 | |
containers: | |
- name: filebeat | |
image: docker.elastic.co/beats/filebeat:6.2.2 | |
args: [ | |
"-c", "/etc/filebeat.yml", | |
"-e", | |
] | |
env: | |
- name: ELASTICSEARCH_HOST | |
value: elasticsearch | |
- name: ELASTICSEARCH_PORT | |
value: "9200" | |
- name: ELASTICSEARCH_USERNAME | |
value: elastic | |
- name: ELASTICSEARCH_PASSWORD | |
value: changeme | |
- name: ELASTIC_CLOUD_ID | |
value: | |
- name: ELASTIC_CLOUD_AUTH | |
value: | |
securityContext: | |
runAsUser: 0 | |
resources: | |
limits: | |
memory: 200Mi | |
requests: | |
cpu: 100m | |
memory: 100Mi | |
volumeMounts: | |
- name: config | |
mountPath: /etc/filebeat.yml | |
readOnly: true | |
subPath: filebeat.yml | |
- name: data | |
mountPath: /usr/share/filebeat/data | |
- name: varlibdockercontainers | |
mountPath: /var/lib/docker/containers | |
readOnly: true | |
volumes: | |
- name: config | |
configMap: | |
defaultMode: 0600 | |
name: filebeat-config | |
- name: varlibdockercontainers | |
hostPath: | |
path: /var/lib/docker/containers | |
# We set an `emptyDir` here to ensure the manifest will deploy correctly. | |
# It's recommended to change this to a `hostPath` folder, to ensure internal data | |
# files survive pod changes (ie: version upgrade) | |
- name: data | |
emptyDir: {} | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: filebeat | |
subjects: | |
- kind: ServiceAccount | |
name: filebeat | |
namespace: kube-system | |
roleRef: | |
kind: ClusterRole | |
name: filebeat | |
apiGroup: rbac.authorization.k8s.io | |
--- | |
apiVersion: rbac.authorization.k8s.io/v1beta1 | |
kind: ClusterRole | |
metadata: | |
name: filebeat | |
labels: | |
k8s-app: filebeat | |
rules: | |
- apiGroups: [""] # "" indicates the core API group | |
resources: | |
- namespaces | |
- pods | |
verbs: | |
- get | |
- watch | |
- list | |
--- | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: filebeat | |
namespace: kube-system | |
labels: | |
k8s-app: filebeat | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment