apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nas-csi-cds-node
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: nas-csi-cds-node
  template:
    metadata:
      labels:
        app: nas-csi-cds-node
    spec:
      tolerations:
        - operator: Exists
      priorityClassName: system-node-critical
      serviceAccount: nas-cds-csi-sa
      hostNetwork: true
      hostPID: true
      containers:
        - name: nas-csi-node-server
          securityContext:
            privileged: true
            capabilities:
              add: ["SYS_ADMIN"]
            allowPrivilegeEscalation: true
          image: registry-bj.capitalonline.net/cck/cds-csi-driver:latest
          imagePullPolicy: "Always"
          args:
            - "--endpoint=$(CSI_ENDPOINT)"
            - "--v=5"
            - "--driver=nas.csi.cds.net"
          env:
            - name: CSI_ENDPOINT
              value: unix://var/lib/kubelet/plugins/nas.csi.cds.net/csi.sock
          volumeMounts:
            - name: kubelet-dir
              mountPath: /var/lib/kubelet/
              mountPropagation: "Bidirectional"
            - name: host-log
              mountPath: /var/log/
            - name: etc
              mountPath: /host/etc
        - name: nas-driver-registrar
          image: registry-bj.capitalonline.net/cck/csi-node-driver-registrar:v1.2.0
          imagePullPolicy: Always
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -rf /registration/nas.csi.cds.net /registration/nas.csi.cds.net-reg.sock"]
          args:
            - "--v=5"
            - "--csi-address=$(ADDRESS)"
            - "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
          env:
            - name: ADDRESS
              value: /var/lib/kubelet/plugins/nas.csi.cds.net/csi.sock
            - name: DRIVER_REG_SOCK_PATH
              value: /var/lib/kubelet/plugins/nas.csi.cds.net/csi.sock
          volumeMounts:
            - name: kubelet-dir
              mountPath: /var/lib/kubelet/
            - name: registration-dir
              mountPath: /registration/
        - name: nas-liveness-probe
          image: registry-bj.capitalonline.net/cck/csi-livenessprobe:v2.0.0
          args:
            - "--csi-address=/var/lib/kubelet/plugins/nas.csi.cds.net/csi.sock"
            - "--health-port=9810"
          volumeMounts:
            - name: kubelet-dir
              mountPath: /var/lib/kubelet/
      volumes:
        - name: kubelet-dir
          hostPath:
            path: /var/lib/kubelet
            type: Directory
        - name: registration-dir
          hostPath:
            path: /var/lib/kubelet/plugins_registry
            type: DirectoryOrCreate
        - name: host-log
          hostPath:
            path: /var/log/
        - name: etc
          hostPath:
            path: /etc
  updateStrategy:
    type: "RollingUpdate"
