
---
# This YAML file contains driver-registrar & csi driver nodeplugin API objects,
# which are necessary to run csi nodeplugin for cinder.

kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: csi-nodeplugin-hxcsi
spec:
  selector:
    matchLabels:
      app: csi-nodeplugin-hxcsi
  template:
    metadata:
      labels:
        app: csi-nodeplugin-hxcsi
    spec:
      serviceAccount: csi-nodeplugin
      hostNetwork: true
      containers:
        - name: csi-driver-registrar
          image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.2
          args:
            - "--csi-address=$(ADDRESS)"
            - "--kubelet-registration-path=/var/lib/kubelet/plugins/csi-hxcsi/csi.sock"
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -rf /registration/csi-hxcsi /registration/csi-hxcsi-reg.sock"]
          env:
            - name: ADDRESS
              value: /plugin/csi.sock
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
              - name: plugin-dir
                mountPath: /plugin
              - name: registration-dir
                mountPath: /registration
        - name: hxcsi
          securityContext:
            privileged: true
            capabilities:
              add: ["SYS_ADMIN"]
            allowPrivilegeEscalation: true
          image: 3pings/hxcsi:1.0.rel.4.0.418.git.468fb557
          args :
            - "--nodeid=$(NODE_ID)"
            - "--endpoint=$(CSI_ENDPOINT)"
          env:
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CSI_ENDPOINT
              value: unix:///plugin/csi.sock
            - name: X_CSI_DEBUG
              value: "true"
            - name: X_CSI_MODE
              value: "node"
            - name: CSI_HX_REST_API_SERVER
              valueFrom:
                configMapKeyRef:
                  name: hxcsi-config
                  key: hxapi_url
            - name: CSI_HX_ISCSI_TARGET_SERVER
              valueFrom:
                configMapKeyRef:
                  name: hxcsi-config
                  key: hxapi_iscsiurl
            - name: CSI_HX_HOST_IP
              valueFrom:
                  fieldRef:
                    fieldPath: status.hostIP
          imagePullPolicy: "IfNotPresent"
          terminationMessagePath: "/tmp/termination-log"
          volumeMounts:
            - name: plugin-dir
              mountPath: /plugin
            - name: pods-mount-dir
              mountPath: /var/lib/kubelet/pods
              mountPropagation: "Bidirectional"
            - name: dev-dir
              mountPath: /dev
            - name: iscsi-dir
              mountPath: /etc/iscsi
            - name: iscsiadm
              mountPath: /sbin/iscsiadm
            - name: lib-dir
              mountPath: /lib/modules
            - name: iscsi-id
              mountPath: /lib/udev/scsi_id
            - name: hxapitoken
              mountPath: "/secrets/hxapi"
      imagePullSecrets:
        - name: hxcsi-dockerimage-secret
      volumes:
        - name: plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/csi-hxcsi
            type: DirectoryOrCreate
        - name: pods-mount-dir
          hostPath:
            path: /var/lib/kubelet/pods
            type: DirectoryOrCreate
        - name: dev-dir
          hostPath:
            path: /dev
            type: Directory
        - name: registration-dir
          hostPath:
            path: /var/lib/kubelet/plugins_registry
            type: Directory
        - name: iscsi-dir
          hostPath:
            path: /etc/iscsi
            type: Directory
        - name: iscsiadm
          hostPath:
            path: /sbin/iscsiadm
            type: File
        - name: lib-dir
          hostPath:
            path: /lib/modules
            type: Directory
        - name: iscsi-id
          hostPath:
            path: /lib/udev/scsi_id
            type: File
        - name: hxapitoken
          secret:
            secretName: hxcsitoken
