kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: hcloud-csi-node
  namespace: kube-system
  labels:
    app: hcloud-csi
spec:
  selector:
    matchLabels:
      app: hcloud-csi
  template:
    metadata:
      labels:
        app: hcloud-csi
    spec:
      tolerations:
      - effect: NoExecute
        operator: Exists
      - effect: NoSchedule
        operator: Exists
      - key: CriticalAddonsOnly
        operator: Exists
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: "instance.hetzner.cloud/is-root-server"
                operator: NotIn
                values:
                - "true"
      containers:
      - name: csi-node-driver-registrar
        image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.2.0
        args:
        - --kubelet-registration-path=/var/lib/kubelet/plugins/csi.hetzner.cloud/socket
        volumeMounts:
        - name: plugin-dir
          mountPath: /run/csi
        - name: registration-dir
          mountPath: /registration
      - name: hcloud-csi-driver
        image: hetznercloud/hcloud-csi-driver:latest
        imagePullPolicy: Always
        command: [/bin/hcloud-csi-driver-node]
        env:
        - name: CSI_ENDPOINT
          value: unix:///run/csi/socket
        - name: METRICS_ENDPOINT
          value: 0.0.0.0:9189
        - name: ENABLE_METRICS
          value: "true"
        volumeMounts:
        - name: kubelet-dir
          mountPath: /var/lib/kubelet
          mountPropagation: "Bidirectional"
        - name: plugin-dir
          mountPath: /run/csi
        - name: device-dir
          mountPath: /dev
        securityContext:
          privileged: true
        ports:
        - containerPort: 9189
          name: metrics
        - name: healthz
          containerPort: 9808
          protocol: TCP
        livenessProbe:
          failureThreshold: 5
          httpGet:
            path: /healthz
            port: healthz
          initialDelaySeconds: 10
          timeoutSeconds: 3
          periodSeconds: 2
      - name: liveness-probe
        imagePullPolicy: Always
        image: k8s.gcr.io/sig-storage/livenessprobe:v2.3.0
        volumeMounts:
        - mountPath: /run/csi
          name: plugin-dir
      volumes:
      - name: kubelet-dir
        hostPath:
          path: /var/lib/kubelet
          type: Directory
      - name: plugin-dir
        hostPath:
          path: /var/lib/kubelet/plugins/csi.hetzner.cloud/
          type: DirectoryOrCreate
      - name: registration-dir
        hostPath:
          path: /var/lib/kubelet/plugins_registry/
          type: Directory
      - name: device-dir
        hostPath:
          path: /dev
          type: Directory
