apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: cloudstack-csi-node
spec:
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: cloudstack-csi-node
  template:
    metadata:
      labels:
        app.kubernetes.io/name: cloudstack-csi-node
        app.kubernetes.io/part-of: cloudstack-csi-driver
    spec:
      containers:
        - args:
            - -endpoint=$(CSI_ENDPOINT)
            - -cloudstackconfig=/etc/cloudstack-csi-driver/cloudstack.ini
            - -nodeName=$(NODE_NAME)
            - -debug
          env:
            - name: CSI_ENDPOINT
              value: unix:///csi/csi.sock
            - name: NODE_HYPERVISOR
              value: vmware
            - name: NODE_MAX_BLOCK_VOLUMES
              value: "10"
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
          image: registry.swisstxt.ch/stxt-proj-cargo-system/cloudstack-csi-driver:latest
          imagePullPolicy: Always
          name: cloudstack-csi-node
          resources: {}
          securityContext:
            privileged: true
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
          - mountPath: /csi
            name: plugin-dir
          - mountPath: /var/lib/kubelet
            mountPropagation: Bidirectional
            name: kubelet-dir
          - mountPath: /dev
            name: device-dir
          - mountPath: /run/cloud-init/
            name: cloud-init-dir
          - mountPath: /etc/cloudstack-csi-driver
            name: cloudstack-conf
          - mountPath: /sys/class/scsi_host/
            name: sys-class-scsi-host-dir
          - mountPath: /sys/class/scsi_device/
            name: sys-class-scsi-device-dir
          - mountPath: /sys/devices
            name: sys-devices
        - args:
            - --csi-address=$(ADDRESS)
            - --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)
            - --v=5
          env:
            - name: ADDRESS
              value: /csi/csi.sock
            - name: DRIVER_REG_SOCK_PATH
              value: /var/lib/kubelet/plugins/csi.cloudstack.apache.org/csi.sock
          image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.0.1
          imagePullPolicy: IfNotPresent
          name: node-driver-registrar
          resources: {}
          securityContext:
            privileged: true
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /csi
              name: plugin-dir
            - mountPath: /registration
              name: registration-dir
      dnsPolicy: ClusterFirst
      nodeSelector:
        kubernetes.io/os: linux
      restartPolicy: Always
      schedulerName: default-scheduler
      serviceAccount: cloudstack-csi-node
      serviceAccountName: cloudstack-csi-node
      terminationGracePeriodSeconds: 30
      tolerations:
        - effect: NoExecute
          operator: Exists
        - effect: NoSchedule
          operator: Exists
      volumes:
        - hostPath:
            path: /var/lib/kubelet/plugins/csi.cloudstack.apache.org/
            type: DirectoryOrCreate
          name: plugin-dir
        - hostPath:
            path: /var/lib/kubelet
            type: Directory
          name: kubelet-dir
        - hostPath:
            path: /dev
            type: Directory
          name: device-dir
        - hostPath:
            path: /var/lib/kubelet/plugins_registry
            type: Directory
          name: registration-dir
        - hostPath:
            path: /run/cloud-init/
            type: Directory
          name: cloud-init-dir
        - hostPath:
            path: /sys/class/scsi_host
            type: Directory
          name: sys-class-scsi-host-dir
        - hostPath:
            path: /sys/class/scsi_device
            type: Directory
          name: sys-class-scsi-device-dir
        - hostPath:
            path: /sys/devices
            type: Directory
          name: sys-devices
        - name: cloudstack-conf
          secret:
            defaultMode: 420
            secretName: csi-cloudstack-secret
  updateStrategy:
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
