apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: openbao-csi-provider
  namespace: openbao
  labels:
    app.kubernetes.io/name: openbao-csi-provider
    app.kubernetes.io/instance: openbao
    app.kubernetes.io/managed-by: Helm
spec:
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app.kubernetes.io/name: openbao-csi-provider
      app.kubernetes.io/instance: openbao
  template:
    metadata:
      labels:
        app.kubernetes.io/name: openbao-csi-provider
        app.kubernetes.io/instance: openbao
    spec:
      serviceAccountName: openbao-csi-provider
      tolerations:
        - effect: NoSchedule
          key: node-role.kubernetes.io/control-plane
          operator: Exists
      containers:
        - name: openbao-csi-provider
          resources:
            requests:
              cpu: 50m
              memory: 100Mi
          image: "quay.io/openbao/openbao-csi-provider:2.0.2@sha256:3cb312e88c62c926caec03bf69497a16805a29daabb5ad2c7a236ab43bb241db"
          imagePullPolicy: IfNotPresent
          args:
            - --endpoint=/provider/openbao.sock
            - --debug=false
            - --hmac-secret-name=openbao-csi-provider-hmac-key
          env:
            - name: VAULT_ADDR
              value: "unix:///var/run/vault/agent.sock"
          volumeMounts:
            - name: providervol
              mountPath: "/provider"
            - name: agent-unix-socket
              mountPath: /var/run/vault
          livenessProbe:
            httpGet:
              path: /health/ready
              port: 8080
            failureThreshold: 2
            initialDelaySeconds: 5
            periodSeconds: 5
            successThreshold: 1
            timeoutSeconds: 3
          readinessProbe:
            httpGet:
              path: /health/ready
              port: 8080
            failureThreshold: 2
            initialDelaySeconds: 5
            periodSeconds: 5
            successThreshold: 1
            timeoutSeconds: 3
        - name: openbao-agent
          image: "quay.io/openbao/openbao:2.5.4@sha256:436eaf9778cad75507ff70ea26ace30dcbe15606e619ac3823495663d7f7c115"
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              cpu: 10m
              memory: 100Mi
          command:
            - bao
          args:
            - agent
            - -config=/etc/vault/config.hcl
          ports:
            - containerPort: 8200
          env:
            - name: BAO_LOG_LEVEL
              value: "info"
            - name: BAO_LOG_FORMAT
              value: "standard"
          securityContext:
            seccompProfile:
              type: RuntimeDefault
            runAsNonRoot: true
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsUser: 100
            runAsGroup: 1000
          volumeMounts:
            - name: agent-config
              mountPath: /etc/vault/config.hcl
              subPath: config.hcl
              readOnly: true
            - name: agent-unix-socket
              mountPath: /var/run/vault
      volumes:
        - name: providervol
          hostPath:
            path: /etc/kubernetes/secrets-store-csi-providers
        - name: agent-config
          configMap:
            name: openbao-csi-provider-agent-config
        - name: agent-unix-socket
          emptyDir:
            medium: Memory
