apiVersion: apps/v1
kind: Deployment
metadata:
  name: fluentd-aggegater
  namespace: logging
  labels:
    app: fluentd-aggegater
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fluentd-aggegater
  template:
    metadata:
      labels:
        app: fluentd-aggegater
    spec:
      serviceAccountName: fluentd
      initContainers:
      - name: fluentd-config
        image: busybox
        command:
        - /bin/sh
        - -c
        - cp /configs/* /fluentd/etc
        volumeMounts:
        - name: fluentd-config-volume
          mountPath: /configs/
        - name: fluentd-config
          mountPath: /fluentd/etc/
      containers:
      - name: fluentd
        image: fluent/fluentd-kubernetes-daemonset:elasticsearch
        env:
          - name:  FLUENT_ELASTICSEARCH_HOST
            value: "es-logging-svc"
          - name:  FLUENT_ELASTICSEARCH_PORT
            value: "9200"
          - name: FLUENT_ELASTICSEARCH_SCHEME
            value: "http"
          # - name: FLUENT_UID
          #   value: "0"
          # - name: FLUENT_ELASTICSEARCH_USER
          #   value: "elastic"
          # - name: FLUENT_ELASTICSEARCH_PASSWORD
          #   value: "changeme"
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: fluentd-config
          mountPath: /fluentd/etc/
      volumes:
      - name: fluentd-config-volume
        configMap:
          name: fluentd-aggegater-config
      - name: fluentd-config
        emptyDir: {}
