---
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: "log-collector"
  namespace: kube-system
  labels:
    app: "log-collector"
    version: v1
spec:
  selector:
    matchLabels:
      app: "log-collector"
  template:
    metadata:
      labels:
        app: "log-collector"
        version: v1
    spec:
      serviceAccount: fluentd
      serviceAccountName: fluentd
      containers:
      - env:
        - name: FLUENTD_ARGS
          value: --no-supervisor -q
        - name: K8S_NODE_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: spec.nodeName
        name: "log-collector"
        image: "${REGISTRY}/library/log-collector:latest"
        imagePullPolicy: Always
        #command: ["sleep", "4800"]
        command: ["fluentd", "-c", "/fluentd/etc/fluent.conf", "-p", "/fluentd/plugins"]
        resources:
          requests:
            memory: "512Mi"
            cpu: "500m"
          limits:
            memory: "512Mi"
            cpu: "500m"
        volumeMounts:
          - name: varlog
            mountPath: /var/log
          - name: varlibdockercontainers
            mountPath: /var/lib/docker/containers
            readOnly: true
          - name: runlogjournal
            mountPath: /run/log/journal
          - name: fluentdconfig
            mountPath: /fluentd/etc
      terminationGracePeriodSeconds: 30
      volumes:
        - name: varlog
          hostPath:
            path: /var/log
        - name: varlibdockercontainers
          hostPath:
            path: /var/lib/docker/containers
        - name: runlogjournal
          hostPath:
            path: /run/log/journal
        - name: fluentdconfig
          configMap:
            name: "fluentd-config"
