kind: Deployment
apiVersion: apps/v1
metadata:
  name: openstack-manila-csi-controllerplugin
  namespace: openshift-manila-csi-driver
  annotations:
    config.openshift.io/inject-proxy: csi-driver
spec:
  selector:
    matchLabels:
      app: openstack-manila-csi
      component: controllerplugin
  replicas: 1
  template:
    metadata:
      labels:
        app: openstack-manila-csi
        component: controllerplugin
    spec:
      nodeSelector:
        node-role.kubernetes.io/master: ""
      serviceAccount: manila-csi-driver-controller-sa
      priorityClassName: system-cluster-critical
      tolerations:
        - key: CriticalAddonsOnly
          operator: Exists
        - key: node-role.kubernetes.io/master
          operator: Exists
          effect: "NoSchedule"
      containers:
        - name: csi-driver
          image: ${DRIVER_IMAGE}
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              memory: 50Mi
              cpu: 10m
          args:
            - --v=${LOG_LEVEL}
            - --cluster-id=${CLUSTER_ID}
            - --nodeid=$(NODE_ID)
            - --endpoint=$(CSI_ENDPOINT)
            - --drivername=$(DRIVER_NAME)
            - --share-protocol-selector=$(MANILA_SHARE_PROTO)
            - --fwdendpoint=$(FWD_CSI_ENDPOINT)
          env:
            - name: DRIVER_NAME
              value: manila.csi.openstack.org
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CSI_ENDPOINT
              value: unix:///plugin/csi.sock
            - name: MANILA_SHARE_PROTO
              value: NFS
            - name: FWD_CSI_ENDPOINT
              value: unix:///plugin/csi-nfs.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /plugin
            - name: cacert
              mountPath: /etc/kubernetes/static-pod-resources/configmaps/cloud-config
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
        # TODO: fix manila CSI driver not to require NFS driver socket!
        - name: csi-driver-nfs
          image: ${NFS_DRIVER_IMAGE}
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              memory: 20Mi
              cpu: 5m
          args:
            - "--nodeid=$(NODE_ID)"
            - "--endpoint=unix://plugin/csi-nfs.sock"
            - "--mount-permissions=0777"
          env:
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: socket-dir
              mountPath: /plugin
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
        - name: csi-provisioner
          image: ${PROVISIONER_IMAGE}
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              memory: 50Mi
              cpu: 10m
          args:
            - --csi-address=$(ADDRESS)
            - --feature-gates=Topology=true
            - --v=${LOG_LEVEL}
            - --http-endpoint=localhost:8202
            - --timeout=120s
          env:
            - name: ADDRESS
              value: /var/lib/csi/sockets/pluginproxy/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /var/lib/csi/sockets/pluginproxy/
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
          # kube-rbac-proxy for external-provisioner container.
          # Provides https proxy for http-based external-provisioner metrics.
        - name: provisioner-kube-rbac-proxy
          args:
          - --secure-listen-address=0.0.0.0:9202
          - --upstream=http://127.0.0.1:8202/
          - --tls-cert-file=/etc/tls/private/tls.crt
          - --tls-private-key-file=/etc/tls/private/tls.key
          - --logtostderr=true
          image: ${KUBE_RBAC_PROXY_IMAGE}
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9202
            name: provisioner-m
            protocol: TCP
          resources:
            requests:
              memory: 20Mi
              cpu: 10m
          volumeMounts:
          - mountPath: /etc/tls/private
            name: metrics-serving-cert
        - name: csi-snapshotter
          image: ${SNAPSHOTTER_IMAGE}
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              memory: 50Mi
              cpu: 10m
          args:
            - --csi-address=$(ADDRESS)
            - --metrics-address=localhost:8203
            - --v=${LOG_LEVEL}
          env:
          - name: ADDRESS
            value: /var/lib/csi/sockets/pluginproxy/csi.sock
          volumeMounts:
          - mountPath: /var/lib/csi/sockets/pluginproxy/
            name: socket-dir
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
        - name: snapshotter-kube-rbac-proxy
          args:
          - --secure-listen-address=0.0.0.0:9203
          - --upstream=http://127.0.0.1:8203/
          - --tls-cert-file=/etc/tls/private/tls.crt
          - --tls-private-key-file=/etc/tls/private/tls.key
          - --logtostderr=true
          image: ${KUBE_RBAC_PROXY_IMAGE}
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9203
            name: snapshotter-m
            protocol: TCP
          resources:
            requests:
              memory: 20Mi
              cpu: 10m
          volumeMounts:
          - mountPath: /etc/tls/private
            name: metrics-serving-cert
      volumes:
        - name: socket-dir
          emptyDir: {}
        - name: cacert
          # If present, extract ca-bundle.pem to
          # /etc/kubernetes/static-pod-resources/configmaps/cloud-config
          # Let the pod start when the ConfigMap does not exist or the certificate
          # is not preset there. The certificate file will be created once the
          # ConfigMap is created / the cerificate is added to it.
          configMap:
            name: cloud-provider-config
            items:
            - key: ca-bundle.pem
              path: ca-bundle.pem
            optional: true
        - name: metrics-serving-cert
          secret:
            secretName: manila-csi-driver-controller-metrics-serving-cert
