apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-s3
  namespace: kube-system
  labels:
    k8s-app: fluentd-s3
spec:
  selector:
    matchLabels:
      k8s-app: fluentd-s3
  template:
    metadata:
      labels:
        k8s-app: fluentd-s3
    spec:
      containers:
        - name: fluentd-s3
          image: ccpgames/kubernetes-fluentd-s3:latest
          imagePullPolicy: Always
          env:
            - name: S3_LOGS_BUCKET_NAME
              valueFrom:
                configMapKeyRef:
                  name: kubernetes-fluentd-s3-config
                  key: S3_LOGS_BUCKET_NAME
            - name: S3_LOGS_BUCKET_PREFIX
              valueFrom:
                configMapKeyRef:
                  name: kubernetes-fluentd-s3-config
                  key: S3_LOGS_BUCKET_PREFIX
            - name: S3_LOGS_BUCKET_REGION
              valueFrom:
                configMapKeyRef:
                  name: kubernetes-fluentd-s3-config
                  key: S3_LOGS_BUCKET_REGION
              # --use-v1-config allows using env vars in config file
              # -qq sets fluentd log level to ERROR
          args:
            - --use-v1-config
            - -qq
          securityContext:
            privileged: true
          resources:
            limits:
              cpu: 100m
          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
