kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: cfs-csi-node
  namespace: default
spec:
  updateStrategy:
    type: OnDelete
  selector:
    matchLabels:
      app: cfs-csi-node
  template:
    metadata:
      labels:
        app: cfs-csi-node
    spec:
      serviceAccount: cfs-csi-service-account
      nodeSelector:
        csi.chubaofs.com/node: enabled
      containers:
        - name: driver-registrar
          image: quay.io/k8scsi/driver-registrar:v0.4.2
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          args:
            - --v=5
            - --csi-address=$(ADDRESS)
            - --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)
            - --kubeconfig=/etc/kubernetes/config
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: ADDRESS
              value: /var/lib/kubelet/plugins/csi.chubaofs.com/csi.sock
            - name: DRIVER_REG_SOCK_PATH
              value: /var/lib/kubelet/plugins/csi.chubaofs.com/csi.sock
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
          resources:
            requests:
              cpu: 200m
              memory: 256Mi
          volumeMounts:
            - mountPath: /var/lib/kubelet/plugins/csi.chubaofs.com
              name: socket-dir
            - mountPath: /registration
              name: registration-dir
            - name: kube-config
              mountPath: /etc/kubernetes
        - name: cfs-driver
          image: chubaofs/cfs-csi-driver:2.1.2
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          command:
            - /bin/tini
            - "--"
            - bash
            - "-c"
            - |-
              set -e
              su -p -s /bin/bash -c "/cfs/bin/start.sh &"
              su -p -s /bin/bash -c "sleep 9999999d"
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: KUBE_CONFIG
              value: /etc/kubernetes/config
            - name: LOG_LEVEL
              value: "5"
            - name: CSI_ENDPOINT
              value: unix:///csi/csi.sock
            - name: DRIVER_NAME
              value: csi.chubaofs.com
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
          resources:
            requests:
              cpu: 1000m
              memory: 2Gi
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
            - mountPath: /var/lib/kubelet/pods
              mountPropagation: Bidirectional
              name: mountpoint-dir
            - name: kube-config
              mountPath: /etc/kubernetes
      volumes:
        - hostPath:
            path: /var/lib/kubelet/plugins/csi.chubaofs.com
            type: DirectoryOrCreate
          name: socket-dir
        - hostPath:
            path: /var/lib/kubelet/plugins/
            type: Directory
          name: registration-dir
        - hostPath:
            path: /var/lib/kubelet/pods
            type: Directory
          name: mountpoint-dir
        - configMap:
            name: csi-kube-config
          name: kube-config
