kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: localstorage-local-storage
  namespace: local-storage-system
spec:
  selector:
    matchLabels:
      app: localstorage-local-storage
  template:
    metadata:
      labels:
        app: localstorage-local-storage
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: localstorage.hwameistor.io/local-storage
                operator: In
                values:
                - "true"
      serviceAccount: storage-admin
      priorityClassName: system-node-critical
      hostNetwork: false
      hostPID: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
        - name: registrar
          image: 10.6.170.180/k8scsi/csi-node-driver-registrar:v1.1.0
          imagePullPolicy: IfNotPresent
          args:
            - "--v=5"
            - "--csi-address=/csi/csi.sock"
            - "--kubelet-registration-path=/var/lib/kubelet/plugins/local.storage.hwameistor.io/csi.sock"
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "rm -rf /registration/local.storage.hwameistor.io /registration/local.storage.hwameistor.io-reg.sock"]
          env:
            - name: KUBE_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
            - name: socket-dir
              mountPath: /csi
            - name: registration-dir
              mountPath: /registration
        - name: member
          image: 10.6.170.180/localstorage/localstorage-local-storage:1.0-integrate_ldm_v1
          imagePullPolicy: Always
          args:
            - --nodename=$(MY_NODENAME)
            - --namespace=$(POD_NAMESPACE)
            - --csi-address=$(CSI_ENDPOINT)
            - --http-port=80
            - --debug=true
          ports:
          - containerPort: 80
            name: healthz
            protocol: TCP
          readinessProbe:
            failureThreshold: 5
            httpGet:
              path: /healthz
              port: healthz
            initialDelaySeconds: 10
            timeoutSeconds: 3
            periodSeconds: 2
          securityContext:
            privileged: true
            capabilities:
              add: ["SYS_ADMIN"]
            allowPrivilegeEscalation: true
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: MY_NODENAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: CSI_ENDPOINT
              value: unix://var/lib/kubelet/plugins/local.storage.hwameistor.io/csi.sock
            - name: NODE_ANNOTATION_KEY_STORAGE_IPV4
              value: localstorage.hwameistor.io/storage-ipv4
          volumeMounts:
            - name: plugin-dir
              mountPath: /var/lib/kubelet/plugins
              mountPropagation: "Bidirectional"
            - name: registration-dir
              mountPath: /var/lib/kubelet/plugins_registry
            - name: pods-mount-dir
              mountPath: /var/lib/kubelet/pods
              mountPropagation: "Bidirectional"
            - name: host-dev
              mountPath: /dev
            - name: host-etc-drbd
              mountPath: /etc/drbd.d
              mountPropagation: "Bidirectional"
      volumes:
        - name: socket-dir
          hostPath:
            path: /var/lib/kubelet/plugins/local.storage.hwameistor.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: host-dev
          hostPath:
            path: /dev
        - name: host-etc-drbd
          hostPath:
            path: /etc/drbd.d
            type: DirectoryOrCreate
        - name: pods-mount-dir
          hostPath:
            path: /var/lib/kubelet/pods
            type: DirectoryOrCreate
