# Copied from https://github.com/kubernetes/kubernetes/
# - removed:
#   - addonmanager.kubernetes.io/mode, kubernetes.io/cluster-service label
#   - serviceAccountName
#   - liveness probe
#   - scheduling annotations
#   - priorityClassName
#   - nodeSelectors
#   - tolerations
#   - terminationGracePeriodSeconds
#   - NODE_NAME, STACKDRIVER_METADATA_AGENT_URL env
#   - hostNetwork: true (otherwise it won't find the metadata server)
# - modified the path to local libs (/usr/lib) because it's different on MIR
# - set the fluentd-gcp-config volume mode to 420
# - added a taint toleration so it runs on all nodes
#
# License: Apache 2.0
# https://github.com/kubernetes/kubernetes/blob/master/LICENSE
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-gcp-v3.2.0
  labels:
    k8s-app: fluentd-gcp
    version: v3.2.0
spec:
  selector:
    matchLabels:
      k8s-app: fluentd-gcp
      version: v3.2.0
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        k8s-app: fluentd-gcp
        version: v3.2.0
    spec:
      dnsPolicy: Default
      containers:
      - name: fluentd-gcp
        image: gcr.io/stackdriver-agents/stackdriver-logging-agent:1.9.3
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
        - mountPath: /host/lib
          name: libsystemddir
          readOnly: true
        - name: config-volume
          mountPath: /etc/google-fluentd/config.d
        - name: default-config-volume
          mountPath: /etc/google-fluentd/google-fluentd.conf
          subPath: google-fluentd.conf
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers
      - name: libsystemddir
        hostPath:
          path: /usr/lib
      - name: config-volume
        configMap:
          name: fluentd-gcp-config-v1.2.5
          defaultMode: 420
      - name: default-config-volume
        configMap:
          name: fluentd-gcp-main-config
          defaultMode: 420
      tolerations:
      - operator: "Exists"
        effect: "NoSchedule"

