# This YAML file contains driver-registrar & csi driver nodeplugin API objects
# that are necessary to run edgefs-csi
# TODO: Specify correct edgefs-csi image to install!!!
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: edgefs-csi-plugin
spec:
  selector:
    matchLabels:
      app: edgefs-csi-plugin
  template:
    metadata:
      labels:
        app: edgefs-csi-plugin
    spec:
      serviceAccount: csi-nodeplugin
      hostNetwork: true
      containers:
        - name: driver-registrar
          image: quay.io/k8scsi/driver-registrar:v0.4.0
          args:
            - "--v=5"
            - "--csi-address=$(ADDRESS)"
          env:
            - name: ADDRESS
              value: /plugin/csi.sock
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: plugin-dir
              mountPath: /plugin
        - name: nfs
          securityContext:
            privileged: true
            capabilities:
              add: ["SYS_ADMIN"]
            allowPrivilegeEscalation: true
          image: edgefs/edgefs-csi:latest
          args :
            - "--v=5"
            - "--nodeid=$(NODE_ID)"
            - "--endpoint=$(CSI_ENDPOINT)"
          env:
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CSI_ENDPOINT
              value: unix://plugin/csi.sock
          imagePullPolicy: "Always"
          volumeMounts:
            - name: plugin-dir
              mountPath: /plugin
            - name: pods-mount-dir
              mountPath: /var/lib/kubelet/pods
              mountPropagation: "Bidirectional"
            - name: secret
              mountPath: /config
      volumes:
        - name: plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/edgefs-csi-plugin
            type: DirectoryOrCreate
        - name: pods-mount-dir
          hostPath:
            path: /var/lib/kubelet/pods
            type: Directory
        - name: secret
          secret:
              secretName: rook-edgefs-cluster
