Node
A Pod asks for a GPU
Device plugins and extended resources
Kubernetes knows nothing about GPUs. It counts CPU and memory itself, and for anything else it relies on a device plugin: a program on the node that tells the kubelet which devices exist and how to hand one to a container. node-2 has one NVIDIA L4. Follow it from the driver, through the device plugin and the scheduler, to nvidia-smi running inside a Pod that asked for nvidia.com/gpu: 1.
- GPU
- NVIDIA L4 · 24 GB · on node-2
- Resource
- nvidia.com/gpu · whole GPUs only
- Installed by
- NVIDIA GPU Operator v26.7
- Kubernetes
- v1.37 · device plugin API v1beta1
Read the whole lesson as text
1. The GPU operator
Several things must be on node-2 before a Pod can use its GPU: the NVIDIA kernel driver, a container runtime that can add the GPU to a container, and the device plugin. NVIDIA's GPU Operator installs all of them as DaemonSets. Its first job is to find the GPU nodes. Node Feature Discovery reads each node's PCI devices and labels node-2, because it has a card from vendor 10de, which is NVIDIA. The operator's DaemonSets select that label, so node-1 gets none of their Pods.
- You install the GPU Operator with its Helm chart.
- Node Feature Discovery on node-2 finds an NVIDIA card on the PCI bus and labels the node.
- The operator labels node-2 as a GPU node and creates one DaemonSet for each part, all selecting that label.
- The DaemonSet controller creates one Pod of each for node-2, and none for node-1.
- node-2's kubelet sees the new Pods on its watch and starts them. The driver goes first.
2. The driver comes first
Look inside node-2. The driver Pod loads NVIDIA's kernel modules, and Linux creates device files for the card: /dev/nvidia0 for the GPU itself, /dev/nvidiactl and /dev/nvidia-uvm for the driver. Every program that uses the GPU goes through these files, inside a container or not. Then the toolkit Pod sets up containerd. With CDI, the Container Device Interface, containerd learns to read files that say exactly what a container needs to use a device.
- The driver Pod loads NVIDIA's kernel modules, and the card shows up as /dev/nvidia0.
- The toolkit Pod configures containerd and restarts it. containerd now reads CDI specs.
3. Register
The device plugin starts. It asks the driver, through the NVML library, which GPUs this node has: one L4. It writes a CDI spec for it under /var/run/cdi. Then it starts a gRPC server on a socket of its own in /var/lib/kubelet/device-plugins/, and calls the kubelet's Registration service on kubelet.sock in the same directory. The request names the API version, the plugin's socket and the resource it serves: nvidia.com/gpu.
- The plugin asks the driver which GPUs node-2 has.
- It writes a CDI spec: what a container needs to use this GPU, under one name.
- It calls the kubelet's Registration service: here is my socket, I serve nvidia.com/gpu.
- The kubelet's device manager connects to the plugin's socket.
4. Advertise
The kubelet opens ListAndWatch, a stream that stays open. The plugin sends its device list: one GPU, Healthy. The kubelet now knows node-2 has one nvidia.com/gpu and writes that into the Node's status, beside CPU and memory. This is all the scheduler will ever know about the card: a resource name and a whole number. Extended resources like this one can't be split or overcommitted, and a Pod asks for them under limits.
- The kubelet opens a stream that the plugin keeps open for as long as it runs.
- The first message on the stream: one device, Healthy.
- The kubelet adds nvidia.com/gpu to node-2's capacity and allocatable.
5. Taint and schedule
A GPU node is expensive, so you keep ordinary Pods off it with a taint. NoSchedule only stops new Pods: the web Pod already on node-2 stays. Then you create llm, which asks for one GPU and tolerates the taint. The scheduler's NodeResourcesFit filter compares nvidia.com/gpu like any other resource: node-1 has none, so it's out. node-2 has one free and its taint is tolerated. The scheduler binds llm to node-2.
- You taint node-2 so only Pods that tolerate it are placed there.
- You create llm: one GPU, under limits, and a toleration for the taint.
- node-1 has no GPU and is filtered out. node-2 has one free and its taint is tolerated.
- The scheduler binds llm to node-2.
6. Allocate
The scheduler only counted. Which GPU llm gets is decided on node-2. Before it starts the Pod's containers, the kubelet's device manager picks a free, healthy device. It asks the plugin which devices it would prefer, then calls Allocate with the chosen ID. The plugin answers with how to give that GPU to a container: here, a CDI device name. The kubelet records the assignment in a checkpoint file, so after a restart it still knows the GPU is taken.
- The kubelet sees llm bound to node-2.
- With several free GPUs, the plugin's preference keeps a Pod's GPUs close together. Here there is one.
- The kubelet tells the plugin which GPU it chose for llm's container.
- The plugin replies with a CDI device name for that GPU.
- The kubelet writes down which Pod holds the GPU, so a restart doesn't hand it out twice.
7. Into the container
After the sandbox and the image pull, the kubelet calls containerd's CreateContainer and passes the CDI device name with it. containerd looks the name up in /var/run/cdi and applies what the spec lists: the device files go into the container, the device cgroup allows them, and the driver's libraries from the host are mounted in. The image carries CUDA but no driver. nvidia-smi starts, reaches the card through /dev/nvidia0 and prints the L4.
- The kubelet asks containerd for the container, with the CDI device name in the request.
- containerd finds the name in the spec and edits the container's OCI spec to match.
- runc starts the container with the GPU's device files and the driver's libraries inside.
- nvidia-smi opens /dev/nvidiactl and /dev/nvidia0, and the driver answers for the card.
- The kubelet reports llm Running.
8. One GPU, one Pod
A device plugin hands out whole devices. While llm holds the L4, a second Pod asking for nvidia.com/gpu: 1 stays Pending, even if llm uses a sliver of it. There are three ways to share. Time-slicing makes the plugin advertise one GPU as several, with no memory isolation between the Pods. MIG cuts an A100, H100 or newer GPU into slices with their own memory, but not an L4. And Dynamic Resource Allocation, GA since Kubernetes v1.34, replaces the count with claims a driver can match against each device's attributes.
- You create llm-2, which also asks for one GPU.
- No node has a free GPU, so llm-2 stays Pending.
9. When the GPU fails
The plugin keeps watching the driver for critical errors, called Xid errors. An hour later the card drops off the PCI bus and the driver reports Xid 79. The plugin marks the device Unhealthy and sends a new list on the ListAndWatch stream that has been open all along. The kubelet lowers allocatable to 0 and leaves capacity at 1. No new Pod is placed on the card. llm keeps its assignment and crashes when it next touches the GPU.
- The driver reports a critical error for the card, and the plugin is listening.
- A new message on the open stream: the same GPU, now Unhealthy.
- The kubelet lowers node-2's allocatable GPUs to 0. The scheduler places no more GPU Pods here.
Summary
To Kubernetes, a GPU is a name and a number. The driver and toolkit make the card usable on the node; the device plugin registers on a Unix socket, reports devices on a stream and turns them into nvidia.com/gpu on the Node. The scheduler only compares counts. The kubelet picks the device and asks the plugin how to hand it over, and CDI tells containerd which device files and libraries to put in the container. Sharing, slicing and claims are what come after that whole number.
Next lesson: List and watch