kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: csi-nodeplugin-fluid
  namespace: fluid-system
spec:
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: csi-nodeplugin-fluid
  template:
    metadata:
      labels:
        app: csi-nodeplugin-fluid
    spec:
      tolerations:
        - operator: Exists
      #priorityClassName: system-node-critical
      hostNetwork: true
      hostPID: true
      containers:
        - name: node-driver-registrar
          # image: <To be injected by patches/csi/injections_in_csi_plugin.yaml>
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -rf /registration/fluid /registration/fuse.csi.fluid.io-reg.sock"]
          args:
            - --v=5
            - --csi-address=/var/lib/kubelet/csi-plugins/fuse.csi.fluid.io/csi.sock
            - --kubelet-registration-path=/var/lib/kubelet/csi-plugins/fuse.csi.fluid.io/csi.sock
          env:
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: kubelet-dir
              mountPath: /var/lib/kubelet/
            - name: registration-dir
              mountPath: /registration
        - name: plugins
          securityContext:
            privileged: true
            runAsUser: 0
            capabilities:
              add: ["SYS_ADMIN"]
            allowPrivilegeEscalation: true
          # image: <To be injected by patches/csi/injections_in_csi_plugin.yaml>
          command: ["/usr/local/bin/entrypoint.sh"]
          args :
            - "--nodeid=$(NODE_ID)"
            - "--endpoint=$(CSI_ENDPOINT)"
            - --v=5
          env:
            - name: NODE_ID
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: CSI_ENDPOINT
              value: unix://var/lib/kubelet/csi-plugins/fuse.csi.fluid.io/csi.sock
          imagePullPolicy: "IfNotPresent"
          volumeMounts:
            - name: plugin-dir
              mountPath: /plugin
            - name: kubelet-dir
              mountPath: /var/lib/kubelet/
              mountPropagation: "Bidirectional"
            - name: fluid-src-dir
              mountPath: /alluxio-mnt
              mountPropagation: "Bidirectional"
      volumes:
        - name: kubelet-dir
          hostPath:
            path: /var/lib/kubelet/
            type: Directory
        - name: plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/csi-fluid-plugin
            type: DirectoryOrCreate
        - hostPath:
            path: /var/lib/kubelet/plugins_registry
            type: DirectoryOrCreate
          name: registration-dir
        - hostPath:
            path: /alluxio-mnt
            type: DirectoryOrCreate
          name: fluid-src-dir
