apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: nvidia-device-plugin-daemonset
  name: nvidia-device-plugin-daemonset
  namespace: gpu-operator-resources
  annotations:
    openshift.io/scc: hostmount-anyuid
spec:
  selector:
    matchLabels:
      app: nvidia-device-plugin-daemonset
  template:
    metadata:
      labels:
        app: nvidia-device-plugin-daemonset
    spec:
      tolerations:
      # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
      # This, along with the annotation above marks this pod as a critical add-on.
      - key: CriticalAddonsOnly
        operator: Exists
      - key: nvidia.com/gpu
        operator: Exists
        effect: NoSchedule
      serviceAccount: nvidia-device-plugin
      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: HostToContainer
      containers:
      - image: "FILLED BY THE OPERATOR"
        name: nvidia-device-plugin-ctr
        securityContext:
          privileged: true
        volumeMounts:
          - name: device-plugin
            mountPath: /var/lib/kubelet/device-plugins
      volumes:
        - name: device-plugin
          hostPath:
            path: /var/lib/kubelet/device-plugins
        - name: run-nvidia
          hostPath:
            path: "/run/nvidia"
            type: Directory
