---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentbit
  namespace: fluentbit
  labels:
    app.kubernetes.io/component: fluentbit
    app.kubernetes.io/name: fluentbit    
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: fluentbit
  template:
    metadata:
      labels:
        app.kubernetes.io/component: fluentbit
        app.kubernetes.io/name: fluentbit
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      priorityClassName: system-node-critical
      serviceAccountName: fluentbit
      terminationGracePeriodSeconds: 10
      containers:
        - name: fluentbit
          image: acraks6jqf6qyt7jarg.azurecr.io/fluent/fluent-bit:1.5
          imagePullPolicy: Always
          ports:
            - containerPort: 2020
          resources:
            limits:
              memory: "512Mi"
              cpu: "1000m"
            requests: 
              memory: "512Mi"
              cpu: "500m"
          env:
            - name: WORKSPACE_ID
              valueFrom:
                secretKeyRef:
                  name: fluentbit-secrets
                  key: WorkspaceId
            - name: SHARED_KEY
              valueFrom:
                secretKeyRef:
                  name: fluentbit-secrets
                  key: SharedKey
            - name: REGION
              valueFrom:
                configMapKeyRef:
                  name: fluentbit-log-config
                  key: region
            - name: ZONE
              valueFrom:
                configMapKeyRef:
                  name: fluentbit-log-config
                  key: zone
            - name: NGSA_LOG
              valueFrom:
                configMapKeyRef:
                  name: fluentbit-log-config
                  key: ngsaLog
            - name: ISTIO_LOG
              valueFrom:
                configMapKeyRef:
                  name: fluentbit-log-config
                  key: istioLog
            - name: LODE_LOG
              valueFrom:
                configMapKeyRef:
                  name: fluentbit-log-config
                  key: lodeLog
          volumeMounts:
            - name: varlog
              mountPath: /var/log
            - name: varlibdockercontainers
              mountPath: /var/lib/docker/containers
              readOnly: true
            - name: fluent-bit-config
              mountPath: /fluent-bit/etc/
      volumes:
        - name: varlog
          hostPath:
            path: /var/log
        - name: varlibdockercontainers
          hostPath:
            path: /var/lib/docker/containers
        - name: fluent-bit-config
          configMap:
            name: fluentbit
