kind: Deployment
apiVersion: apps/v1
metadata:
  name: cfs-csi-controller
  namespace: cubefs
spec:
  selector:
    matchLabels:
      app: cfs-csi-controller
  replicas: 1
  template:
    metadata:
      labels:
        app: cfs-csi-controller
    spec:
      serviceAccount: cfs-csi-service-account
      nodeSelector:
        cubefs-csi-controller: enabled
      containers:
        - name: csi-provisioner
          image: quay.io/k8scsi/csi-provisioner:v1.6.0
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          args:
            - --provisioner=csi.cubefs.com
            - --csi-address=$(ADDRESS)
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: ADDRESS
              value: /csi/csi-controller.sock
          resources:
            requests:
              cpu: 200m
              memory: 256Mi
          # limits:
          #   cpu: 500m
          #   memory: 512Mi
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
        - name: csi-attacher
          image: quay.io/k8scsi/csi-attacher:v2.0.0
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          args:
            - --csi-address=$(ADDRESS)
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: ADDRESS
              value: /csi/csi-controller.sock
          resources:
            requests:
              cpu: 200m
              memory: 256Mi
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
        - name: csi-resizer
          image: quay.io/k8scsi/csi-resizer:v0.5.0
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          args:
            - --csi-address=$(ADDRESS)
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: ADDRESS
              value: /csi/csi-controller.sock
          resources:
            requests:
              cpu: 200m
              memory: 256Mi
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
        - name: cfs-driver
          image: ghcr.io/cubefs/cfs-csi-driver:2.4.1.110.1
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          args:
            - 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: LOG_LEVEL
              value: "5"
            - name: CSI_ENDPOINT
              value: unix:///csi/csi-controller.sock
            - name: DRIVER_NAME
              value: csi.cubefs.com
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
          lifecycle:
            preStop:
              exec:
                command: [
                  "/bin/sh", "-c",
                  "rm -rf /csi/csi-controller.sock"
                ]
          resources:
            requests:
              cpu: 200m
              memory: 256Mi
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
            - mountPath: /var/lib/kubelet/pods
              mountPropagation: Bidirectional
              name: mountpoint-dir
      volumes:
        - hostPath:
            path: /var/lib/kubelet/plugins/csi.cubefs.com
            type: DirectoryOrCreate
          name: socket-dir
        - hostPath:
            path: /var/lib/kubelet/pods
            type: Directory
          name: mountpoint-dir
