---
# Source: fcfs-csi-driver/templates/node.yaml
# Node Service
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: fcfs-csi-node
  labels:
    app.kubernetes.io/name: fcfs-csi-driver
spec:
  selector:
    matchLabels:
      app: fcfs-csi-node
      app.kubernetes.io/name: fcfs-csi-driver
  template:
    metadata:
      labels:
        app: fcfs-csi-node
        app.kubernetes.io/name: fcfs-csi-driver
    spec:
      nodeSelector:
        kubernetes.io/os: linux
      hostNetwork: true
      serviceAccountName: fcfs-csi-node-sa
      priorityClassName: system-node-critical
      tolerations:
        - key: CriticalAddonsOnly
          operator: Exists
        - operator: Exists
          effect: NoExecute
          tolerationSeconds: 300
      containers:
        - name: fcfs-plugin
          securityContext:
            privileged: true
            capabilities:
              add: [ "SYS_ADMIN" ]
          image: vazmin/fcfs-csi:v0.2.0
          args:
            - --node-server=true
            - --endpoint=$(CSI_ENDPOINT)
            - --nodeid=$(CSI_NODE_NAME)
            - --v=4
            - "--domain-labels=kubernetes.io/hostname"
          env:
            - name: CSI_ENDPOINT
              value: unix://csi/csi.sock
            - name: CSI_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: kubelet-dir
              mountPath: /var/lib/kubelet
              mountPropagation: "Bidirectional"
            - name: socket-dir
              mountPath: /csi
            - name: device-dir
              mountPath: /dev
            - mountPath: /etc/fcfs-csi-config/
              name: fcfs-csi-config
            - mountPath: /tmp/csi/keys
              name: keys-tmp-dir
          ports:
            - name: healthz
              containerPort: 9808
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /healthz
              port: healthz
            initialDelaySeconds: 10
            timeoutSeconds: 3
            periodSeconds: 10
            failureThreshold: 5
        - name: node-driver-registrar
          image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.1.0
          args:
            - --csi-address=$(ADDRESS)
            - --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)
            - --v=5
          env:
            - name: ADDRESS
              value: /csi/csi.sock
            - name: DRIVER_REG_SOCK_PATH
              value: /var/lib/kubelet/plugins/fcfs.csi.vazmin.github.io/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
            - name: registration-dir
              mountPath: /registration
        - name: liveness-probe
          image: k8s.gcr.io/sig-storage/livenessprobe:v2.2.0
          args:
            - --csi-address=$(ADDRESS)
          env:
            - name: ADDRESS
              value: /csi/csi.sock
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
      volumes:
        - name: kubelet-dir
          hostPath:
            path: /var/lib/kubelet
            type: Directory
        - name: socket-dir
          hostPath:
            path: /var/lib/kubelet/plugins/fcfs.csi.vazmin.github.io/
            type: DirectoryOrCreate
        - name: plugin-dir
          hostPath:
            path: /var/lib/kubelet/plugins/
            type: DirectoryOrCreate
        - name: registration-dir
          hostPath:
            path: /var/lib/kubelet/plugins_registry/
            type: Directory
        - name: device-dir
          hostPath:
            path: /dev
            type: Directory
        - name: fcfs-csi-config
          configMap:
            name: fcfs-csi-config
        - name: keys-tmp-dir
          emptyDir: {
            medium: "Memory"
          }
