---
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: huawei-csi-node
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: huawei-csi-node
  template:
    metadata:
      labels:
        app: huawei-csi-node
    spec:
      serviceAccountName: huawei-csi-node
      hostNetwork: true
      containers:
        - name: csi-node-driver-registrar
          image: quay.io/k8scsi/csi-node-driver-registrar:v2.0.1
          args:
            - "--csi-address=/csi/csi.sock"
            - "--kubelet-registration-path=/var/lib/kubelet/plugins/csi.huawei.com/csi.sock"
          imagePullPolicy: "IfNotPresent"
          volumeMounts:
            - name: plugin-dir
              mountPath: /csi
            - name: registration-dir
              mountPath: /registration

        - name: huawei-csi-driver
          image: huawei-csi:*.*.*
          args:
            - "--endpoint=/csi/csi.sock"
            - "--containerized"
            - "--driver-name=csi.huawei.com"
          securityContext:
            privileged: true
            capabilities:
              add: ["SYS_ADMIN"]
            allowPrivilegeEscalation: true
          imagePullPolicy: "IfNotPresent"
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -f /csi/csi.sock"]
          volumeMounts:
            - name: plugin-dir
              mountPath: /csi
            - name: pods-dir
              mountPath: /var/lib/kubelet
              mountPropagation: "Bidirectional"
            - name: etc-dir
              mountPath: /etc
            - name: log-dir
              mountPath: /var/log
            - name: dev-dir
              mountPath: /dev
              mountPropagation: "HostToContainer"
            - name: iscsi-dir
              mountPath: /var/lib/iscsi
            - name: config-map
              mountPath: /etc/huawei

      volumes:
        - name: plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/csi.huawei.com
            type: DirectoryOrCreate
        - name: registration-dir
          hostPath:
            path: /var/lib/kubelet/plugins_registry
            type: Directory
        - name: pods-dir
          hostPath:
            path: /var/lib/kubelet
            type: Directory
        - name: etc-dir
          hostPath:
            path: /etc
            type: Directory
        - name: dev-dir
          hostPath:
            path: /dev
            type: Directory
        - name: iscsi-dir
          hostPath:
            path: /var/lib/iscsi
        - name: log-dir
          hostPath:
            path: /var/log/
            type: Directory
        - name: config-map
          configMap:
            name: huawei-csi-configmap
