apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: gpu-feature-discovery
  namespace: "FILLED BY THE OPERATOR"
  labels:
    app: gpu-feature-discovery
    app.kubernetes.io/part-of: nvidia-gpu
spec:
  selector:
    matchLabels:
      app: gpu-feature-discovery
      app.kubernetes.io/part-of: nvidia-gpu
  template:
    metadata:
      labels:
        app: gpu-feature-discovery
        app.kubernetes.io/part-of: nvidia-gpu
    spec:
      nodeSelector:
        nvidia.com/gpu.deploy.gpu-feature-discovery: "true"
      tolerations:
        - key: nvidia.com/gpu
          operator: Exists
          effect: NoSchedule
      priorityClassName: system-node-critical
      serviceAccount: nvidia-gpu-feature-discovery
      initContainers:
        - name: toolkit-validation
          image: "FILLED BY THE OPERATOR"
          command: ['sh', '-c']
          args: ["until [ -f /run/nvidia/validations/toolkit-ready ]; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
          securityContext:
            privileged: true
          volumeMounts:
            - name: run-nvidia
              mountPath: /run/nvidia
              mountPropagation: Bidirectional
      containers:
        - image: "FILLED BY THE OPERATOR"
          name: gpu-feature-discovery
          env:
            - name: GFD_SLEEP_INTERVAL
              value: 60s
            - name: GFD_FAIL_ON_INIT_ERROR
              value: "true"
          volumeMounts:
            - name: output-dir
              mountPath: "/etc/kubernetes/node-feature-discovery/features.d"
            - name: dmi-product-name
              mountPath: "/proc/device-tree/model"
          securityContext:
            privileged: true
      volumes:
        - name: output-dir
          hostPath:
            path: "/etc/kubernetes/node-feature-discovery/features.d"
        - name: dmi-product-name
          hostPath:
            path: "/proc/device-tree/model"
        - name: run-nvidia
          hostPath:
            path: "/run/nvidia"
            type: Directory
