# Deployment DaemonSet
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-es-v3.2.0
  namespace: logging
  labels:
    k8s-app: fluentd-es
    version: v3.2.0
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  selector:
    matchLabels:
      k8s-app: fluentd-es
      version: v3.2.0
  template:
    metadata:
      labels:
        k8s-app: fluentd-es
        version: v3.2.0
      # This annotation ensures that fluentd does not get evicted if the node
      # supports cirtical pod annotation based priority scheme.
      # Not that this does not grarantee admission on the nodes (#40573).
      annotations:
        seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
    spec:
      priorityClassName: system-node-critical
      serviceAccountName: fluentd-es
      # nodeSelector:
      #  beta.kubernetes.io/fluentd-ds-ready: "true"
      containers:
      - name: fluentd-es
        image: ${DOCKER_HUB}/quay.io/fluentd_elasticsearch/fluentd:v3.2.0
        imagePullPolicy: IfNotPresent
        env:
        - name: FLUENTD_ARGS
          value: --no-supervisor -q
        resources:
          limits:
            memory: 500Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        # - name: varlibdockercontainers
        #   mountPath: /var/lib/docker/containers
        #   readOnly: true
        #
        # mount another direcory because changing --data-root in docker daemon
        - name: appdatadockercontainers
          mountPath: ${DOCKER_DATA_ROOT}/containers
          readOnly: true
        - name: config-volume
          mountPath: /etc/fluent/config.d
        ports:
        - containerPort: 24231
          name: prometheus
          protocol: TCP
        livenessProbe:
          tcpSocket:
            port: prometheus
          initialDelaySeconds: 5
          timeoutSeconds: 10
        readinessProbe:
          tcpSocket:
            port: prometheus
          initialDelaySeconds: 5
          timeoutSeconds: 10
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      # - name: varlibdockercontainers
      #   hostPath:
      #     path: /var/lib/docker/containers
      #
      # another path specified because changing --data-root value in docker daemon
      - name: appdatadockercontainers
        hostPath:
          path: ${DOCKER_DATA_ROOT}/containers
      - name: config-volume
        configMap:
          name: fluentd-es-config-v0.2.1
