apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluent-bit
  labels:
    app: fluent-bit
spec:
  selector:
    matchLabels:
      app: fluent-bit
  template:
    metadata:
      labels:
        app: fluent-bit
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "2020"
        prometheus.io/path: /api/v1/metrics/prometheus
    spec:
      containers:
      - name: fluent-bit
        image: registry.homelab.dsb.dev/fluent/fluent-bit:arm64v8-1.6.8
        imagePullPolicy: Always
        env:
          - name: PG_HOST
            value: postgres.storage.svc.cluster.local
          - name: PG_PORT
            value: "5432"
          - name: PG_USER
            valueFrom:
              secretKeyRef:
                key: postgres.user
                name: postgres
          - name: PG_PASSWORD
            valueFrom:
              secretKeyRef:
                key: postgres.password
                name: postgres
        readinessProbe:
          httpGet:
            port: 2020
            path: /api/v1/uptime
        volumeMounts:
          - name: logs
            mountPath: /var/log
          - name: config
            mountPath: /fluent-bit/etc/
      terminationGracePeriodSeconds: 10
      volumes:
      - name: logs
        hostPath:
          path: /var/log
      - name: config
        configMap:
          name: fluent-bit
      serviceAccountName: fluent-bit
      tolerations:
        - key: node-role.kubernetes.io/master
          operator: Exists
          effect: NoSchedule
        - operator: "Exists"
          effect: "NoExecute"
        - operator: "Exists"
          effect: "NoSchedule"
