## PaperTrail example Daemonset
# Uncomment sections below to allow audit logs to go to a separate host

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-ds-papertrail
  namespace: kube-system
  labels:
    name: fluentd-logging
    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:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: fluentd
        image: fluent/fluentd-kubernetes-daemonset:v1-debian-papertrail
        env:
          - name: FLUENT_PAPERTRAIL_HOST
            value: "logsX.papertrailapp.com"
          - name: FLUENT_PAPERTRAIL_PORT
            value: "XXXXX"
#          - name: FLUENT_PAPERTRAIL_AUDIT_HOST
#            value: "<PAPERTRAIL_AUDIT_HOST>"
#          - name: FLUENT_PAPERTRAIL_AUDIT_PORT
#            value: "<PAPERTRAIL_AUDIT_PORT>"
          - name: FLUENT_HOSTNAME
            value: "MYCLUSTER"
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        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
#---
#apiVersion: v1
#kind: ConfigMap
#metadata:
#  name: fluentd-config
#  namespace: kube-system
#  labels:
#    k8s-app: fluentd-logging
#    version: v1
#data:
#  fluent.conf: |-
#    @include kubernetes.conf
#
#    # Capture audit logs
#    <match kube-apiserver-audit>
#      type papertrail
#
#      papertrail_host "#{ENV['FLUENT_PAPERTRAIL_AUDIT_HOST']}"
#      papertrail_port "#{ENV['FLUENT_PAPERTRAIL_AUDIT_PORT']}"
#    </match>
#
#    # Capture all unmatched tags
#    <match **>
#      type papertrail
#
#      papertrail_host "#{ENV['FLUENT_PAPERTRAIL_HOST']}"
#      papertrail_port "#{ENV['FLUENT_PAPERTRAIL_PORT']}"
#    </match>
