---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-ds-graylog
  namespace: kube-system
  labels:
    k8s-app: fluentd-logging
    version: v1
spec:
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      name: fluentd-logging
      k8s-app: fluentd-logging
      version: v1
  template:
    metadata:
      labels:
        name: fluentd-logging
        k8s-app: fluentd-logging
        version: v1
    spec:
      serviceAccount: fluentd
      serviceAccountName: fluentd
      # Enable tolerations if you want to run daemonset on master nodes.
      # Recommended to disable on managed k8s.
      # tolerations:
      # - key: node-role.kubernetes.io/master
      #   effect: NoSchedule
      containers:
      - name: fluentd
        image: fluent/fluentd-kubernetes-daemonset:v1-debian-graylog
        imagePullPolicy: IfNotPresent
        env:
          - name:  FLUENT_GRAYLOG_HOST
            value: "graylog-server-ip-or-dns-name"
          - name:  FLUENT_GRAYLOG_PORT
            value: "12201"
        resources:
          requests:
            cpu: 200m
            memory: 0.5Gi
          limits:
            # ===========
            # Less memory leads to child process problems.
            cpu: 1000m
            memory: 1Gi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers
