---
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: csi-curve-plugin
  namespace: csi-system
spec:
  selector:
    matchLabels:
      app: csi-curve-plugin
  updateStrategy:
    type: OnDelete
  template:
    metadata:
      labels:
        app: csi-curve-plugin
    spec:
      serviceAccountName: curve-csi-nodeplugin
      hostNetwork: true
      hostPID: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
      - name: driver-registrar
        image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.2.0
        securityContext:
          privileged: true
        args:
        - "--v=5"
        - "--csi-address=/csi/csi.sock"
        - "--kubelet-registration-path=/var/lib/kubelet/plugins/curve.csi.netease.com/csi.sock"
        env:
        - name: KUBE_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        volumeMounts:
        - name: socket-dir
          mountPath: /csi
        - name: registration-dir
          mountPath: /registration
      - name: csi-curveplugin
        securityContext:
          privileged: true
          capabilities:
            add: ["SYS_ADMIN"]
          allowPrivilegeEscalation: true
        image: harbor.cloud.netease.com/qzprod-k8s/k8scsi/curve-csi:v2.0.0
        args:
        - --endpoint=$(CSI_ENDPOINT)
        - --drivername=curve.csi.netease.com
        - --nodeid=$(NODE_ID)
        - --node-server=true
        - --debug-port=9595
        - --logtostderr=false
        - --log_dir=/var/log/csi-curveplugin
        - -v=4
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: NODE_ID
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: CSI_ENDPOINT
          value: unix:///csi/csi.sock
        volumeMounts:
        - name: socket-dir
          mountPath: /csi
        - mountPath: /dev
          name: host-dev
        - mountPath: /sys
          name: host-sys
        - mountPath: /lib/modules
          name: lib-modules
          readOnly: true
        - name: plugin-dir
          mountPath: /var/lib/kubelet/plugins
          mountPropagation: "Bidirectional"
        - name: mountpoint-dir
          mountPath: /var/lib/kubelet/pods
          mountPropagation: "Bidirectional"
        - mountPath: /etc/localtime
          name: localtime
        - mountPath: /var/log/csi-curveplugin
          name: log
      volumes:
      - name: socket-dir
        hostPath:
          path: /var/lib/kubelet/plugins/curve.csi.netease.com
          type: DirectoryOrCreate
      - name: plugin-dir
        hostPath:
          path: /var/lib/kubelet/plugins
          type: Directory
      - name: mountpoint-dir
        hostPath:
          path: /var/lib/kubelet/pods
          type: DirectoryOrCreate
      - name: registration-dir
        hostPath:
          path: /var/lib/kubelet/plugins_registry/
          type: Directory
      - name: host-dev
        hostPath:
          path: /dev
      - name: host-sys
        hostPath:
          path: /sys
      - name: lib-modules
        hostPath:
          path: /lib/modules
      - name: localtime
        hostPath:
          path: /etc/localtime
      - name: log
        hostPath:
          path: /var/log/csi-curveplugin
