k8s部署filebeat 采集应用程序日志

公司的服务都部署在k8s上,日志采集成为必须要做的事;

filebeat采集日志有两种方案:
1.filebeat跟应用程序一同部署,放在一个pod内,filebeat作为sidecar监控应用程序的日志;
2.filebeat作为守护类pod采集每个节点上的应用程序日志;
由于每个节点上的应用程序还不是特别多,所以一个filebeat可以搞定,故放弃在每个应用程序的pod内添加filebeat的方案。

filebeat yaml

apiVersion: apps/v1
kind: DaemonSet
metadata:
  annotations:
    deprecated.daemonset.template.generation: '44'
  creationTimestamp: '2021-12-25T13:56:32Z'
  generation: 44
  labels:
    k8s-app: filebeat
  name: filebeat
  namespace: lzzk
spec:
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s-app: filebeat
  template:
    metadata:
      labels:
        k8s-app: filebeat
    spec:
      containers:
        - args:
            - '-c'
            - /etc/filebeat.yml
            - '-e'
          env:
            - name: ELASTICSEARCH_HOST
              value: 172.17.12.2
            - name: ELASTICSEARCH_PORT
              value: '9967'
            - name: ELASTICSEARCH_USERNAME
            - name: ELASTICSEARCH_PASSWORD
            - name: ELASTIC_CLOUD_ID
            - name: ELASTIC_CLOUD_AUTH
          image: 'docker.elastic.co/beats/filebeat:6.6.2'
          imagePullPolicy: IfNotPresent
          name: filebeat
          resources:
            limits:
              cpu: 300m
              memory: 200Mi
            requests:
              cpu: 100m
              memory: 100Mi
          securityContext:
     

你可能感兴趣的:(k8s,docker,kubernetes,elasticsearch)