apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluent-bit
  labels:
    app.kubernetes.io/name: fluent-bit
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: fluent-bit
  template:
    metadata:
      labels:
        app.kubernetes.io/name: fluent-bit
    spec:
      serviceAccountName: fluent-bit
      terminationGracePeriodSeconds: 10
      containers:
        - name: fluent-bit
          image: fluent/fluent-bit:1.8
          command:
            - /fluent-bit/bin/fluent-bit
            - --config=/etc/fluent-bit/fluent-bit.conf
            - --quiet
          env:
            - name: FLB_ES_HOST
              value: "elasticsearch.logging"
            - name: FLB_ES_PORT
              value: "9200"
          ports:
            - containerPort: 2020
          resources:
            requests:
              cpu: 50m
              memory: 50Mi
            limits:
              cpu: 500m
              memory: 500Mi
          livenessProbe:
            httpGet:
              path: /api/v1/health
              port: 2020
          volumeMounts:
            - name: runlogjournal
              mountPath: /run/log/journal
            - name: varlog
              mountPath: /var/log
            - name: varlibdockercontainers
              mountPath: /var/lib/docker/containers
              readOnly: true
            - name: etcmachineid
              mountPath: /etc/machine-id
              readOnly: true
            - name: fluent-bit-conf
              mountPath: /etc/fluent-bit/
      volumes:
        - name: runlogjournal
          hostPath:
            path: /run/log/journal
        - name: varlog
          hostPath:
            path: /var/log
        - name: varlibdockercontainers
          hostPath:
            path: /var/lib/docker/containers
        - name: etcmachineid
          hostPath:
            path: /etc/machine-id
            type: File
        - name: fluent-bit-conf
          configMap:
            name: fluent-bit-conf
      tolerations:
        - operator: Exists
          effect: NoExecute
        - operator: Exists
          effect: NoSchedule
