apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-disk-manager
spec:
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      name: node-disk-manager
  template:
    metadata:
      labels:
        name: node-disk-manager
    spec:
      # By default the node-disk-manager will be run on all kubernetes nodes
      # If you would like to limit this to only some nodes, say the nodes
      # that have storage attached, you could label those node and use nodeSelector.
      # Example: Label the storage nodes with - "openebs.io/nodegroup"="storage-node"
      # kubectl label node <node-name> "openebs.io/nodegroup"="storage-node"
      # nodeSelector:
      #   "openebs.io/nodegroup": "storage-node"
      # Use host network as container network to monitor udev source using netlink
      # to detect disk attach and detach events using fd.
      hostNetwork: true
      serviceAccountName: openebs-ndm-operator
      containers:
        - name: node-disk-manager
          image: openebs/node-disk-manager-amd64:ci
          args:
            - -v=2
          #          - --feature-gates="GPTBasedUUID"
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          # make udev database available inside container
          volumeMounts:
            - name: config
              mountPath: /host/node-disk-manager.config
              subPath: node-disk-manager.config
              readOnly: true
            - name: udev
              mountPath: /run/udev
            - name: procmount
              mountPath: /host/proc
              readOnly: true
            - name: sparsepath
              mountPath: /var/openebs
          env:
            # namespace in which NDM is installed will be passed to NDM Daemonset
            # as environment variable
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            # pass hostname as env variable using downward API to the NDM container
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            # specify the directory where the sparse files need to be created.
            # if not specified, then sparse files will not be created.
            - name: SPARSE_FILE_DIR
              value: "/var/openebs"
            # Size of the sparse file to be created.
            - name: SPARSE_FILE_SIZE
              value: "1073741824"
            # Specify the number of sparse files to be created
            - name: SPARSE_FILE_COUNT
              value: "1"
      volumes:
        - name: config
          configMap:
            name: node-disk-manager-config
        - name: udev
          hostPath:
            path: /run/udev
            type: Directory
        - name: procmount
          # mount /proc/1/mounts (mount file of process 1 of host) inside container
          # to read which partition is mounted on / path
          hostPath:
            path: /proc
            type: Directory
        - name: sparsepath
          hostPath:
            path: /var/openebs
