apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: vector
  labels:
    app.kubernetes.io/name: vector
    app.kubernetes.io/instance: vector
    app.kubernetes.io/component: Agent
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: vector
      app.kubernetes.io/instance: vector
      app.kubernetes.io/component: Agent
  template:
    metadata:
      labels:
        app.kubernetes.io/name: vector
        app.kubernetes.io/instance: vector
        app.kubernetes.io/component: Agent
        vector.dev/exclude: "true"
    spec:
      serviceAccountName: vector
      dnsPolicy: ClusterFirst
      containers:
        - name: vector
          image: "timberio/vector:0.19.0-distroless-libc"
          imagePullPolicy: IfNotPresent
          args:
            - --config-dir
            - /etc/vector/
          env:
            - name: VECTOR_SELF_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: VECTOR_SELF_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: VECTOR_SELF_POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: PROCFS_ROOT
              value: "/host/proc"
            - name: SYSFS_ROOT
              value: "/host/sys"
          ports:
            - name: prom-exporter
              containerPort: 9090
              protocol: TCP
          volumeMounts:
            - mountPath: /tlscerts/certs
              name: mtlscerts
            - mountPath: /tlscerts/ca
              name: mtlsca
            - name: data
              mountPath: "/vector-data-dir"
            - name: config
              mountPath: "/etc/vector/"
              readOnly: true
            - name: var-log
              mountPath: "/var/log/"
              readOnly: true
            - name: var-lib
              mountPath: "/var/lib"
              readOnly: true
            - name: procfs
              mountPath: "/host/proc"
              readOnly: true
            - name: sysfs
              mountPath: "/host/sys"
              readOnly: true
      terminationGracePeriodSeconds: 60
      volumes:
        - name: mtlscerts
          secret:
            defaultMode: 420
            secretName: client-cert
        - name: mtlsca
          secret:
            defaultMode: 420
            secretName: managed-cluster-cert
        - name: config
          projected:
            sources:
              - configMap:
                  name: vector
        - name: data
          hostPath:
            path: "/var/lib/vector"
        - name: var-log
          hostPath:
            path: "/var/log/"
        - name: var-lib
          hostPath:
            path: "/var/lib/"
        - name: procfs
          hostPath:
            path: "/proc"
        - name: sysfs
          hostPath:
            path: "/sys"
