apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: nfd-worker
  name: nfd-worker
spec:
  selector:
    matchLabels:
      app: nfd-worker
  template:
    metadata:
      labels:
        app: nfd-worker
    spec:
      nodeSelector:
        node-role.kubernetes.io/worker: ""
      tolerations:
      - operator: Exists
      - key: nvidia.com/gpu
        operator: Exists
        effect: NoSchedule
      hostNetwork: true
      serviceAccount: nfd-worker
      readOnlyRootFilesystem: true
      containers:
        - env:
          - name: NODE_NAME
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
          image: $(NODE_FEATURE_DISCOVERY_IMAGE)
          name: nfd-worker
          command:
            - "nfd-worker"
          args:
            - "--sleep-interval=60s"
            - "--server=$(NFD_MASTER_SERVICE_HOST):$(NFD_MASTER_SERVICE_PORT)"
          volumeMounts:
            - name: host-boot
              mountPath: "/host-boot"
              readOnly: true
            - name: host-os-release
              mountPath: "/host-etc/os-release"
              readOnly: true
            - name: host-sys
              mountPath: "/host-sys"
            - name: config
              mountPath: "/etc/kubernetes/node-feature-discovery"
            - name: nfd-hooks
              mountPath: "/etc/kubernetes/node-feature-discovery/source.d"
            - name: nfd-features
              mountPath: "/etc/kubernetes/node-feature-discovery/features.d"
          securityContext:
            readOnlyRootFilesystem: true
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
      volumes:
        - name: host-boot
          hostPath:
            path: "/boot"
        - name: host-os-release
          hostPath:
            path: "/etc/os-release"
        - name: host-sys
          hostPath:
            path: "/sys"
        - name: nfd-hooks
          hostPath:
            path: "/etc/kubernetes/node-feature-discovery/source.d"
        - name: nfd-features
          hostPath:
            path: "/etc/kubernetes/node-feature-discovery/features.d"
        - name: config 
          configMap:
            name: nfd-worker
            items:
              - key: nfd-worker-conf
                path: nfd-worker.conf


