---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: cbs-csi-controller
  namespace: kube-system
spec:
  replicas: 2
  selector:
    matchLabels:
      app: cbs-csi-controller
  template:
    metadata:
      labels:
        app: cbs-csi-controller
    spec:
      serviceAccountName: cbs-csi-controller-sa
      priorityClassName: system-cluster-critical
      containers:
        - name: csi-provisioner
          image: quay.io/k8scsi/csi-provisioner:v1.6.0
          args:
            - "--feature-gates=Topology=true"
            - "--csi-address=$(ADDRESS)"
            - "--v=5"
            - "--timeout=120s"
            - "--enable-leader-election"
            - "--leader-election-type=leases"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 100Mi
        - name: csi-attacher
          image: quay.io/k8scsi/csi-attacher:v2.2.0
          args:
            - "--csi-address=$(ADDRESS)"
            - "--v=5"
            - "--leader-election=true"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 100Mi
        - name: csi-snapshotter
          image: quay.io/k8scsi/csi-snapshotter:v2.1.0
          args:
            - "--csi-address=$(ADDRESS)"
            - "--leader-election=true"
            - "--v=5"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 100Mi
        - name: snapshot-controller
          image: quay.io/k8scsi/snapshot-controller:v2.1.0
          args:
            - "--v=5"
            - "--leader-election=true"
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 100Mi
        - name: csi-resizer
          image: quay.io/k8scsi/csi-resizer:v0.5.0
          args:
            - "--csi-address=$(ADDRESS)"
            - "--v=5"
            - "--leader-election=true"
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 100Mi
        - name: cbs-csi
          image: ccr.ccs.tencentyun.com/k8scsi/csi-tencentcloud-cbs:v1.2.0
          command:
          - "/csi-tencentcloud-cbs"
          args:
          - "--v=5"
          - "--logtostderr=true"
          - "--endpoint=$(ADDRESS)"
          env:
            - name: ADDRESS
              value: unix:///csi/csi.sock
            - name: TENCENTCLOUD_API_SECRET_ID
              valueFrom:
                secretKeyRef:
                  name: cbs-csi-api-key
                  key: TENCENTCLOUD_CBS_API_SECRET_ID
                  optional: true
            - name: TENCENTCLOUD_API_SECRET_KEY
              valueFrom:
                secretKeyRef:
                  name: cbs-csi-api-key
                  key: TENCENTCLOUD_CBS_API_SECRET_KEY
                  optional: true
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
# for deleting cbs disks in cluster while deleting cluster
#            - name: CLUSTER_ID
#              value: cls-xxxxxx
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 100Mi
      volumes:
        - name: socket-dir
          emptyDir: {}
