kind: Deployment
apiVersion: apps/v1
metadata:
  name: csi-gce-pd-controller
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gcp-compute-persistent-disk-csi-driver
  template:
    metadata:
      labels:
        app: gcp-compute-persistent-disk-csi-driver
    spec:
      # Host network must be used for interaction with Workload Identity in GKE
      # since it replaces GCE Metadata Server with GKE Metadata Server. Remove
      # this requirement when issue is resolved and before any exposure of
      # metrics ports
      hostNetwork: true
      nodeSelector:
        kubernetes.io/os: linux
      serviceAccountName: csi-gce-pd-controller-sa
      priorityClassName: csi-gce-pd-controller
      containers:
        - name: csi-provisioner
          image: gke.gcr.io/csi-provisioner
          args:
            - "--v=5"
            - "--csi-address=/csi/csi.sock"
            - "--feature-gates=Topology=true"
            - "--metrics-address=:22011"
            - "--enable-leader-election"
            - "--leader-election-type=leases"
            - "--leader-election-namespace=$(PDCSI_NAMESPACE)"
          # - "--run-controller-service=false" # disable the controller service of the CSI driver
          # - "--run-node-service=false"       # disable the node service of the CSI driver
          env:
            - name: PDCSI_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
        - name: csi-attacher
          image: gke.gcr.io/csi-attacher
          args:
            - "--v=5"
            - "--csi-address=/csi/csi.sock"
            - "--metrics-address=:22012"
            - "--leader-election"
            - "--leader-election-namespace=$(PDCSI_NAMESPACE)"
          env:
            - name: PDCSI_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
        - name: csi-resizer
          image: gke.gcr.io/csi-resizer
          args:
            - "--v=5"
            - "--csi-address=/csi/csi.sock"
            - "--metrics-address=:22013"
            - "--leader-election"
            - "--leader-election-namespace=$(PDCSI_NAMESPACE)"
          env:
            - name: PDCSI_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
        - name: csi-snapshotter
          image: gke.gcr.io/csi-snapshotter
          args:
            - "--v=5"
            - "--csi-address=/csi/csi.sock"
            - "--metrics-address=:22014"
            - "--leader-election"
            - "--leader-election-namespace=$(PDCSI_NAMESPACE)"
          env:
            - name: PDCSI_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
        - name: gce-pd-driver
          # Don't change base image without changing pdImagePlaceholder in
          # test/k8s-integration/main.go
          image: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
          args:
            - "--v=5"
            - "--endpoint=unix:/csi/csi.sock"
          env:
            - name: GOOGLE_APPLICATION_CREDENTIALS
              value: "/etc/cloud-sa/cloud-sa.json"
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
            - name: cloud-sa-volume
              readOnly: true
              mountPath: "/etc/cloud-sa"
      volumes:
        - name: socket-dir
          emptyDir: {}
        - name: cloud-sa-volume
          secret:
            secretName: cloud-sa
