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:
      dnsPolicy: ClusterFirstWithHostNet
      tolerations:
        - operator: "Exists"
          effect: "NoSchedule"
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: node-role.kubernetes.io/master
                    operator: DoesNotExist
              - matchExpressions:
                  - key: node-role.kubernetes.io/worker
                    operator: Exists
      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:12000"
          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
