apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: gpu-feature-discovery
  namespace: gpu-operator-resources
  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:
      serviceAccount: nvidia-gpu-feature-discovery
      containers:
        - image: "FILLED BY THE OPERATOR"
          name: gpu-feature-discovery
          command: ["sh", "-c"]
          args: ["export SYS_LIBRARY_PATH=$(ldconfig -v 2>/dev/null | grep -v '^[[:space:]]' | cut -d':' -f1 | tr '[[:space:]]' ':'); \
          export NVIDIA_LIBRARY_PATH=/run/nvidia/driver/usr/lib/x86_64-linux-gnu/:/run/nvidia/driver/usr/lib64; \
          export LD_LIBRARY_PATH=${SYS_LIBRARY_PATH}:${NVIDIA_LIBRARY_PATH}; echo ${LD_LIBRARY_PATH}; gpu-feature-discovery"]
          volumeMounts:
            - name: output-dir
              mountPath: "/etc/kubernetes/node-feature-discovery/features.d"
            - name: dmi-product-name
              mountPath: "/sys/class/dmi/id/product_name"
            - name: nvidia-install-path
              mountPath: /run/nvidia
              mountPropagation: Bidirectional
          env:
            - name: GFD_SLEEP_INTERVAL
              value: 60s
            - name: GFD_MIG_STRATEGY
              value: none
            - name: GFD_FAIL_ON_INIT_ERROR
              value: "false"
          securityContext:
            privileged: true
      nodeSelector:
        nvidia.com/gpu.present: "true"
      volumes:
        - name: output-dir
          hostPath:
            path: "/etc/kubernetes/node-feature-discovery/features.d"
        - name: dmi-product-name
          hostPath:
            path: "/sys/class/dmi/id/product_name"
        - name: nvidia-install-path
          hostPath:
            path: /run/nvidia
