apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: log-pilot
  namespace: logging
  labels:
    k8s-app: log-pilot
spec:
  selector:
    matchLabels:
      k8s-app: log-pilot
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        k8s-app: log-pilot
      annotations:
        scheduler.alpha.kubernetes.io/critical-pod: ''
    spec:
      # 是否允许部署到Master节点上tolerations。
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      #serviceAccount: log-pilot
      containers:
      - name: log-pilot
        image: slpcat/log-pilot:0.9.7-filebeat-7.15.0
        resources:
          # keep request = limit to keep this container in guaranteed class
          requests:
            cpu: 500m
            memory: 512Mi
          limits:
            cpu: 4
            memory: 8Gi
        env:
          - name: "PILOT_LOG_PREFIX"
            value: "aliyun,custom"
          - name: "LOGGING_OUTPUT"
            value: "kafka"
          - name: "KAFKA_BROKERS"
            value: "kafka1:9092,kafka2:9092"
          - name: "KAFKA_VERSION"
            value: "0.10.0"
          #- name: "KAFKA_USERNAME"
          #  value: ""
          #- name: "KAFKA_PASSWORD"
          #  value: ""
          #- name: "KAFKA_PARTITION_KEY"
          #  value: ""
          #- name: "KAFKA_PARTITION"
          #  value: ""
          - name: "KAFKA_WORKER"
            value: "4"
          - name: "KAFKA_CLIENT_ID"
            value: "beats"
          - name: "KAFKA_BROKER_TIMEOUT"
            value: "60"
          - name: "KAFKA_KEEP_ALIVE"
            value: "300s"
          - name: "KAFKA_REQUIRE_ACKS"
            value: "0"
          - name: "KAFKA_BULK_MAX_SIZE"
            value: "16384"
          - name: "KAFKA_CHANNEL_BUFFER_SIZE"
            value: "4096"
          - name: "KAFKA_MAX_MESSAGE_BYTES"
            value: "10000000"
          - name: "KAFKA_COMPRESSION"
            value: "none"
          - name: "FILEBEAT_MAX_PROCS"
            value: "4"
          - name: "FILEBEAT_LOG_LEVEL"
            value: "info"
          - name: "NODE_NAME"
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
        volumeMounts:
        - name: sock
          mountPath: /var/run/docker.sock
        - name: logs
          mountPath: /var/log/filebeat
        - name: state
          mountPath: /var/lib/filebeat
        - name: root
          mountPath: /host
          readOnly: true
        livenessProbe:
          failureThreshold: 3
          exec:
            command:
            - /pilot/healthz
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 2
        securityContext:
          capabilities:
            add:
            - SYS_ADMIN
      terminationGracePeriodSeconds: 30
      volumes:
      - name: sock
        hostPath:
          path: /var/run/docker.sock
      - name: logs
        hostPath:
          path: /var/log/filebeat
          type: DirectoryOrCreate
      - name: state
        hostPath:
          path: /var/lib/filebeat
          type: DirectoryOrCreate
      - name: root
        hostPath:
          path: /
