kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: openstack-manila-csi-nodeplugin
  namespace: openshift-manila-csi-driver
spec:
  selector:
    matchLabels:
      app: openstack-manila-csi
      component: nodeplugin
  template:
    metadata:
      labels:
        app: openstack-manila-csi
        component: nodeplugin
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      serviceAccount: manila-csi-driver-node-sa
      priorityClassName: system-node-critical
      tolerations:
        - operator: Exists
      containers:
        - name: csi-driver
          securityContext:
            privileged: true
          image: ${DRIVER_IMAGE}
          resources:
            requests:
              memory: 50Mi
              cpu: 10m
          args:
            - --v=${LOG_LEVEL}
            - "--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:///var/lib/kubelet/plugins/manila.csi.openstack.org/csi.sock
            - name: FWD_CSI_ENDPOINT
              value: unix:///var/lib/kubelet/plugins/csi-nfsplugin/csi.sock
            - name: MANILA_SHARE_PROTO
              value: NFS
          volumeMounts:
            - name: plugin-dir
              mountPath: /var/lib/kubelet/plugins/manila.csi.openstack.org
            - name: fwd-plugin-dir
              mountPath: /var/lib/kubelet/plugins/csi-nfsplugin
            - name: cacert
              mountPath: /usr/share/pki/ca-trust-source
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
        - name: csi-node-driver-registrar
          securityContext:
            privileged: true
          image: ${NODE_DRIVER_REGISTRAR_IMAGE}
          resources:
            requests:
              memory: 20Mi
              cpu: 5m
          args:
            - --v=${LOG_LEVEL}
            - --csi-address=/csi/csi.sock
            - --kubelet-registration-path=/var/lib/kubelet/plugins/manila.csi.openstack.org/csi.sock
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -rf /var/lib/kubelet/plugins/manila.csi.openstack.org/csi.sock"]
          env:
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: plugin-dir
              mountPath: /csi
            - name: registration-dir
              mountPath: /registration
          resources:
            requests:
              cpu: 5m
              memory: 20Mi
      volumes:
        - name: registration-dir
          hostPath:
            path: /var/lib/kubelet/plugins_registry/
            type: Directory
        - name: plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/manila.csi.openstack.org
            type: DirectoryOrCreate
        - name: fwd-plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/csi-nfsplugin
            type: DirectoryOrCreate
        - name: cacert
          # Extract ca-bundle.pem to /usr/share/pki/ca-trust-source if present.
          # 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
