kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: csi-imageplugin
spec:
  selector:
    matchLabels:
      app: csi-imageplugin
  template:
    metadata:
      labels:
        app: csi-imageplugin
    spec:
      hostNetwork: true
      containers:
        - name: node-driver-registrar
          image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0
          imagePullPolicy: IfNotPresent
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -rf /registration/csi-image /registration/csi-image-reg.sock"]
          args:
            - --v=5
            - --csi-address=/csi/csi.sock
            - --kubelet-registration-path=/var/lib/kubelet/plugins/csi-image/csi.sock
          env:
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
          volumeMounts:
          - mountPath: /csi
            name: socket-dir
          - mountPath: /registration
            name: registration-dir

        - name: image
          image: quay.io/k8scsi/imagepopulatorplugin:canary
#          image: quay.io/k8scsi/imagepopulatorplugin:debug
#          ports:
#            - containerPort: 2345
          args:
            - "--v=5"
            - "--endpoint=$(CSI_ENDPOINT)"
            - "--nodeid=$(KUBE_NODE_NAME)"
          env:
            - name: CSI_ENDPOINT
              value: unix:///csi/csi.sock
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
          imagePullPolicy: Always
          securityContext:
            privileged: true
          volumeMounts:
            - mountPath: /csi
              name: socket-dir
            - mountPath: /var/lib/kubelet/pods
              mountPropagation: Bidirectional
              name: mountpoint-dir
            - mountPath: /var/lib/containers/storage
              mountPropagation: Bidirectional
              name: storageroot-dir
            - mountPath: /var/run/containers/storage
              mountPropagation: Bidirectional
              name: storagerunroot-dir

      volumes:
        - hostPath:
            path: /var/lib/kubelet/plugins/csi-image
            type: DirectoryOrCreate
          name: socket-dir
        - hostPath:
            path: /var/lib/kubelet/pods
            type: DirectoryOrCreate
          name: mountpoint-dir
        - hostPath:
            path: /var/lib/kubelet/plugins_registry
            type: Directory
          name: registration-dir
        - hostPath:
            path: /var/lib/containers/storage
            type: DirectoryOrCreate
          name: storageroot-dir
        - hostPath:
            path: /var/run/containers/storage
            type: DirectoryOrCreate
          name: storagerunroot-dir

