kind: Deployment 
apiVersion: apps/v1
metadata:
  name: vsphere-csi-controller
  namespace: vmware-system-csi
spec:
  strategy:
    type: Recreate
  replicas: 1
  selector:
    matchLabels:
      app: vsphere-csi-controller
  template:
    metadata:
      labels:
        app: vsphere-csi-controller
        role: vsphere-csi
    spec:
      serviceAccount: vsphere-csi-controller
      nodeSelector:
        node-role.kubernetes.io/master: ''
      tolerations:
        - operator: "Exists"
          key: "node-role.kubernetes.io/master"
          effect: "NoSchedule"
      hostNetwork: true
      containers:
        - name: csi-provisioner
          image: vmware/csi-provisioner/csi-provisioner:v1.2.1_vmware.2
          args:
            - "--v=4"
            - "--timeout=300s"
            - "--csi-address=$(ADDRESS)"
            - "--feature-gates=Topology=true"
            - "--strict-topology"
            - "--enable-leader-election"
            - "--leader-election-type=leases"
          env:
            - name: ADDRESS
              value: /var/lib/csi/sockets/pluginproxy/csi.sock
            - name: KUBERNETES_SERVICE_HOST
              value: "127.0.0.1"
            - name: KUBERNETES_SERVICE_PORT
              value: "6443"
            - name: VSPHERE_CLOUD_OPERATOR_SERVICE_PORT
              value: "29000"
          imagePullPolicy: "IfNotPresent"
          volumeMounts:
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
        - name: csi-attacher
          image: vmware/csi-attacher/csi-attacher:v1.1.1
          args:
            - "--v=4"
            - "--timeout=300s"
            - "--csi-address=$(ADDRESS)"
            - "--leader-election"
            - "--leader-election-type=leases"
          env:
            - name: ADDRESS
              value: /var/lib/csi/sockets/pluginproxy/csi.sock
            - name: KUBERNETES_SERVICE_HOST
              value: "127.0.0.1"
            - name: KUBERNETES_SERVICE_PORT
              value: "6443"
          imagePullPolicy: "IfNotPresent"
          volumeMounts:
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
        - name: vsphere-csi-controller
          image: vmware/vsphere-csi:<vsphere_csi_ver>
          args:
            - "--supervisor-fss-name=csi-feature-states"
            - "--supervisor-fss-namespace=$(CSI_NAMESPACE)"
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -rf /var/lib/csi/sockets/pluginproxy/csi.vsphere.vmware.com"]
          env:
            - name: CSI_ENDPOINT
              value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
            - name: CLUSTER_FLAVOR
              value: "WORKLOAD"
            - name: X_CSI_MODE
              value: "controller"
            - name: KUBERNETES_SERVICE_HOST
              value: "127.0.0.1"
            - name: KUBERNETES_SERVICE_PORT
              value: "6443"
            - name: POD_LISTENER_SERVICE_PORT
              value: "29000"
            - name: VSPHERE_CSI_CONFIG
              value: "/etc/vmware/wcp/vsphere-cloud-provider.conf" # here vsphere-cloud-provider.conf is the name of the file used for creating secret using "--from-file" flag
            - name: LOGGER_LEVEL
              value: "PRODUCTION" # Options: DEVELOPMENT, PRODUCTION
            - name: INCLUSTER_CLIENT_QPS
              value: "50"
            - name: INCLUSTER_CLIENT_BURST
              value: "50"
            - name: CSI_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          imagePullPolicy: "IfNotPresent"
          volumeMounts:
            - mountPath: /etc/vmware/wcp
              name: vsphere-config-volume
              readOnly: true
            - mountPath: /var/lib/csi/sockets/pluginproxy/
              name: socket-dir
        - name: liveness-probe
          image: vmware/csi-livenessprobe/csi-livenessprobe:v1.1.0
          args:
            - "--csi-address=$(ADDRESS)"
          env:
            - name: ADDRESS
              value: /var/lib/csi/sockets/pluginproxy/csi.sock
          volumeMounts:
            - mountPath: /var/lib/csi/sockets/pluginproxy/
              name: socket-dir
        - name: vsphere-syncer
          image: vmware/syncer:<syncer_ver>
          args:
            - "--leader-election"
            - "--supervisor-fss-name=csi-feature-states"
            - "--supervisor-fss-namespace=$(CSI_NAMESPACE)"
          env:
            - name: CLUSTER_FLAVOR
              value: "WORKLOAD"
            - name: KUBERNETES_SERVICE_HOST
              value: "127.0.0.1"
            - name: KUBERNETES_SERVICE_PORT
              value: "6443"
            - name: FULL_SYNC_INTERVAL_MINUTES
              value: "30"
            - name: POD_POLL_INTERVAL_SECONDS
              value: "2"
            - name: POD_LISTENER_SERVICE_PORT
              value: "29000"
            - name: VSPHERE_CSI_CONFIG
              value: "/etc/vmware/wcp/vsphere-cloud-provider.conf" # here vsphere-cloud-provider.conf is the name of the file used for creating secret using "--from-file" flag
            - name: LOGGER_LEVEL
              value: "PRODUCTION" # Options: DEVELOPMENT, PRODUCTION
            - name: CSI_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          imagePullPolicy: "IfNotPresent"
          volumeMounts:
            - mountPath: /etc/vmware/wcp
              name: vsphere-config-volume
              readOnly: true
      volumes:
        - name: vsphere-config-volume
          secret:
            secretName: vsphere-config-secret
        - name: socket-dir
          hostPath:
            path: /var/lib/csi/sockets/pluginproxy/csi.vsphere.vmware.com
            type: DirectoryOrCreate