apiVersion: extensions/v1beta1
kind: "DaemonSet"
metadata:
  name: "{{daemonset_name}}"
  labels:
    provider: openshift
    component: "{{daemonset_component}}"
    logging-infra: "{{daemonset_component}}"
spec:
  selector:
    matchLabels:
      provider: openshift
      component: "{{daemonset_component}}"
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      minReadySeconds: 600
  template:
    metadata:
      name: "{{daemonset_container_name}}"
      labels:
        logging-infra: "{{daemonset_component}}"
        provider: openshift
        component: "{{daemonset_component}}"
    spec:
      serviceAccountName: "{{daemonset_serviceAccount}}"
      nodeSelector:
        {{fluentd_nodeselector_key}}: "{{fluentd_nodeselector_value}}"
      containers:
      - name: "{{daemonset_container_name}}"
        image: "{{openshift_logging_image_prefix}}{{daemonset_name}}:{{openshift_logging_image_version}}"
        imagePullPolicy: Always
        securityContext:
          privileged: true
        resources:
          limits:
            cpu: {{openshift_logging_fluentd_cpu_limit}}
            memory: {{openshift_logging_fluentd_memory_limit}}
        volumeMounts:
        - name: runlogjournal
          mountPath: /run/log/journal
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
        - name: config
          mountPath: /etc/fluent/configs.d/user
          readOnly: true
        - name: certs
          mountPath: /etc/fluent/keys
          readOnly: true
        - name: dockerhostname
          mountPath: /etc/docker-hostname
          readOnly: true
        - name: localtime
          mountPath: /etc/localtime
          readOnly: true
        - name: dockercfg
          mountPath: /etc/sysconfig/docker
          readOnly: true
        env:
        - name: "K8S_HOST_URL"
          value: "{{master_url}}"
        - name: "ES_HOST"
          value: "{{openshift_logging_es_host}}"
        - name: "ES_PORT"
          value: "{{openshift_logging_es_port}}"
        - name: "ES_CLIENT_CERT"
          value: "{{openshift_logging_es_client_cert}}"
        - name: "ES_CLIENT_KEY"
          value: "{{openshift_logging_es_client_key}}"
        - name: "ES_CA"
          value: "{{openshift_logging_es_ca}}"
        - name: "OPS_HOST"
          value: "{{ops_host}}"
        - name: "OPS_PORT"
          value: "{{ops_port}}"
        - name: "OPS_CLIENT_CERT"
          value: "{{openshift_logging_es_ops_client_cert}}"
        - name: "OPS_CLIENT_KEY"
          value: "{{openshift_logging_es_ops_client_key}}"
        - name: "OPS_CA"
          value: "{{openshift_logging_es_ops_ca}}"
        - name: "ES_COPY"
          value: "{{openshift_logging_fluentd_es_copy|lower}}"
        - name: "ES_COPY_HOST"
          value: "{{es_copy_host | default('')}}"
        - name: "ES_COPY_PORT"
          value: "{{es_copy_port | default('')}}"
        - name: "ES_COPY_SCHEME"
          value: "{{es_copy_scheme | default('https')}}"
        - name: "ES_COPY_CLIENT_CERT"
          value: "{{es_copy_client_cert | default('')}}"
        - name: "ES_COPY_CLIENT_KEY"
          value: "{{es_copy_client_key | default('')}}"
        - name: "ES_COPY_CA"
          value: "{{es_copy_ca | default('')}}"
        - name: "ES_COPY_USERNAME"
          value: "{{es_copy_username | default('')}}"
        - name: "ES_COPY_PASSWORD"
          value: "{{es_copy_password | default('')}}"
        - name: "OPS_COPY_HOST"
          value: "{{ops_copy_host | default('')}}"
        - name: "OPS_COPY_PORT"
          value: "{{ops_copy_port | default('')}}"
        - name: "OPS_COPY_SCHEME"
          value: "{{ops_copy_scheme | default('https')}}"
        - name: "OPS_COPY_CLIENT_CERT"
          value: "{{ops_copy_client_cert | default('')}}"
        - name: "OPS_COPY_CLIENT_KEY"
          value: "{{ops_copy_client_key | default('')}}"
        - name: "OPS_COPY_CA"
          value: "{{ops_copy_ca | default('')}}"
        - name: "OPS_COPY_USERNAME"
          value: "{{ops_copy_username | default('')}}"
        - name: "OPS_COPY_PASSWORD"
          value: "{{ops_copy_password | default('')}}"
        - name: "USE_JOURNAL"
          value: "{{openshift_logging_fluentd_use_journal|lower}}"
        - name: "JOURNAL_SOURCE"
          value: "{{fluentd_journal_source | default('')}}"
        - name: "JOURNAL_READ_FROM_HEAD"
          value: "{{openshift_logging_fluentd_journal_read_from_head|lower}}"
      volumes:
      - name: runlogjournal
        hostPath:
          path: /run/log/journal
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers
      - name: config
        configMap:
          name: logging-fluentd
      - name: certs
        secret:
          secretName: logging-fluentd
      - name: dockerhostname
        hostPath:
          path: /etc/hostname
      - name: localtime
        hostPath:
          path: /etc/localtime
      - name: dockercfg
        hostPath:
          path: /etc/sysconfig/docker
