AI lab, part 3: Kubernetes
The same emulated GPU cluster on Kubernetes: GPU pods, Kueue topology-aware queueing, JobSet and monitoring. Part 2 ran the lab under Slurm. This part uses Kubernetes as the scheduler on the same hardware. Slurm does GPU allocation, topology and queueing on its own. Kubernetes wasn’t designed for batch GPU work, so it needs add-ons for them. The main one is Kueue, which adds job queues and quotas for CPU, memory and GPUs. I’ll show which add-on does what, how GPUs and NVLink topology (Part 1) look in Kubernetes, how the same jobs run as pods, and how Kueue queues them. To switch, set Kubernetes describes hardware with node labels, which pods and queues can select on. Two of them carry the NVLink topology, The two trays are worker nodes. The controller runs the control plane and add-ons, and is tainted so pods don’t land on it. Both trays carry the same NVLink clique, the ID of the NVLink partition their GPUs are in ( GFD adds about 25 more topograph adds two labels for the InfiniBand network between trays (Part 7): Kubernetes has no job queue of its own: the scheduler places each pod as soon as it’s created. Kueue adds queues, quotas and all-or-nothing admission for multi-pod jobs. A ClusterQueue holds the quota, and a LocalQueue in each user’s namespace submits to it: In Kubernetes, A device plugin is how Kubernetes learns about hardware it doesn’t know natively. It advertises a resource such as The lab doesn’t use NVIDIA’s device plugin, because it needs a real driver installation. It uses its own small plugin, Kueue handles topology, like A workload annotated with No Kueue and no JobSet, just a pod asking for two GPUs: The image comes from The pod sees exactly two GPUs, here GPUs 0 and 1 of The repository’s That’s eight pods, each holding one different GPU, all in clique 1. DDP works the same way: two pods with four GPUs each, and The default run is only 50 steps. After the first step, which includes warm-up, a step takes between 4.0 and 4.3 ms, in the same range as the same job under Slurm in Part 2. As there, the step time is simulated, and the loss values are not real. These are the same admin tasks as in Part 2, done the Kubernetes way: queueing jobs when the GPUs are busy, and taking a tray out of service. Start a longer DDP run, No pods are created while the workload is suspended, so nothing sits half-scheduled holding GPUs. When the DDP run finishes, Cordoning marks a node unschedulable while leaving its running pods alone, the Kubernetes counterpart of a Slurm drain. It’s the Kubernetes half of the power-cycle runbook from Part 4. Cordoning needs admin rights, so it runs on the host: Then, as Kueue sees that only one tray’s worth of GPUs is schedulable inside the domain and holds the whole gang. After Cluster state reaches Prometheus through kube-state-metrics (NodePort 30808): nodes and their allocatable GPUs, pods’ GPU requests, Jobs and their status. Recording rules turn it into the same Grafana’s Lab overview dashboard shows the same DDP run on the trays: All eight GPUs move together, as they did under Slurm: A Job that Kueue keeps suspended counts as While the job runs, the pods’ GPU work is visible on the trays as it would be for any process: The same worker appears as PID 22749 on the tray and PID 16 inside the pod: each viewer sees the process under the PID from its own namespace, as with the real driver. Part 6 walks through both dashboards and what to read from each graph. Part 4: BMCs and Redfish goes below the scheduler, to the management controllers that power trays on and off and switch NVLinks.All parts
Table of contents
Overview
scheduler: k3s in local.yml, then run make down && make up (Part 1). Commands that start with bin/ run on the host, from the repository root. All other commands run on the login node as joe (bin/ssh login), whose kubeconfig and namespace are already set up. bin/kubectl runs kubectl on the host with the cluster-admin kubeconfig; commands that need admin rights use it.Looking at the cluster
nvidia.com/gpu.clique and accelerator.topograph.run/domain:$ kubectl get nodes -L nvidia.com/gpu.clique,accelerator.topograph.run/domain
NAME STATUS ROLES AGE VERSION GPU.CLIQUE DOMAIN
sched-control Ready control-plane 5m12s v1.36.5+k3s1
sched-worker1 Ready <none> 4m56s v1.36.5+k3s1 7f3c2a10-5b4e-4d6a-9c1e-2b8f0e6d4a91.1 7f3c2a10-5b4e-4d6a-9c1e-2b8f0e6d4a91.1
sched-worker2 Ready <none> 4m56s v1.36.5+k3s1 7f3c2a10-5b4e-4d6a-9c1e-2b8f0e6d4a91.1 7f3c2a10-5b4e-4d6a-9c1e-2b8f0e6d4a91.1<cluster UUID>.<clique ID>, the same clique 1 Slurm’s jobs reported in Part 2), and two different components publish it. nvidia.com/gpu.clique comes from NVIDIA’s GPU Feature Discovery (GFD), which reads it from NVML. accelerator.topograph.run/domain comes from topograph, which rebuilds it from the live NVLink and InfiniBand fabric every minute.$ kubectl get nodes -o custom-columns='NODE:.metadata.name,GPU:.status.allocatable.nvidia\.com/gpu,PRODUCT:.metadata.labels.nvidia\.com/gpu\.product,MEM:.metadata.labels.nvidia\.com/gpu\.memory'
NODE GPU PRODUCT MEM
sched-control <none> <none> <none>
sched-worker1 4 NVIDIA-GB200 189471
sched-worker2 4 NVIDIA-GB200 189471nvidia.com/* labels per tray. It reads them from NVML, so they’re the labels a real GB200 tray would get. For example:nvidia.com/gpu.family=blackwellnvidia.com/gpu.compute.major=10nvidia.com/cuda.driver-version.full=580.95.05nvidia.com/cuda.runtime-version.full=13.0fabric.topograph.run/tier-0: the leaf switch the tray is plugged intofabric.topograph.run/tier-1: the spine switch that connects the leaves$ kubectl get clusterqueues
NAME COHORT PENDING WORKLOADS
gpu 0
$ kubectl get localqueues
NAME CLUSTERQUEUE PENDING WORKLOADS ADMITTED WORKLOADS
default gpu 0 0
gpu gpu 0 0joe gets a namespace of their own, also called joe. Their kubeconfig on the login node sets it as the default namespace, so every pod or job they create without -n lands there. They can create pods and JobSets there and read nodes and queues, but they can’t touch other namespaces or cluster-wide queue objects:$ kubectl auth can-i create jobsets.jobset.x-k8s.io
yes
$ kubectl auth can-i create pods -n kube-system
noHow Kubernetes is configured for GPUs
sched-control, agents on the trays, all in unprivileged Incus containers.fakedp and CDI: a device plugin advertising nvidia.com/gpu, 4 per tray. Each GPU is a CDI device in /etc/cdi/fakegpu.json that injects /dev/nvidia<n> and the emulated driver.gpu (8 CPUs, 18 GiB, 8 GPUs). In each user namespace, a LocalQueue gpu and a default one for workloads without a queue label. Topology-aware scheduling.nvidia.com/gpu on each node, and when a pod lands there, it tells the container runtime which devices to hand over. CDI (Container Device Interface) is the format for that hand-over: a spec file listing, per device, what to inject into the container.fakedp, which hands out GPUs by UUID through CDI:$ bin/ssh sched-worker1 'jq -c "{kind, devices: [.devices[].name]}" /etc/cdi/fakegpu.json'
{"kind":"nvidia.com/gpu","devices":["0","GPU-81501924-f170-f6d0-f2da-dc7595876881","1","GPU-8150a4ae-…", …]}topology/block in Slurm. Its Topology object, nvl, orders the node labels from coarse to fine:$ bin/kubectl get topology nvl -o jsonpath='{.spec.levels}' | jq -c '[.[].nodeLabel]'
["fabric.topograph.run/tier-1","fabric.topograph.run/tier-0","accelerator.topograph.run/domain","kubernetes.io/hostname"]kueue.x-k8s.io/podset-required-topology: accelerator.topograph.run/domain is admitted only if all its pods fit inside one NVLink domain. The pods of a multi-pod job are admitted together, as a gang, or not at all. Without that, a DDP job could start half its ranks and hold their GPUs while waiting for the rest.Running jobs
A single GPU pod
apiVersion: v1
kind: Pod
metadata:
name: gpu-pod
spec:
restartPolicy: Never
containers:
- name: smi
image: mirror.gcr.io/library/buildpack-deps:noble
command: [nvidia-smi, -L]
resources:
limits: {nvidia.com/gpu: 2}mirror.gcr.io, Google’s public cache of popular Docker Hub images, so pulls don’t count against Docker Hub’s anonymous rate limit. Plain docker.io names work too: each tray pulls them through the same mirror.$ kubectl apply -f gpu-pod.yaml
pod/gpu-pod created
$ kubectl logs gpu-pod
GPU 0: NVIDIA GB200 (UUID: GPU-81501924-f170-f6d0-f2da-dc7595876881)
GPU 1: NVIDIA GB200 (UUID: GPU-8150a4ae-478e-5534-f66c-621a95f85f59)sched-worker1. Whichever GPUs it gets, they’re numbered from 0 inside the pod, just as with the real driver. nvidia-smi and CUDA agree on what the pod has, because CDI only injects the allocated device nodes. The pod has no queue label, but Kueue still takes it: it goes to the LocalQueue named default in joe’s namespace (a queue, not the default namespace) and is admitted against the same ClusterQueue quota as everything else, so nobody can grab GPUs by skipping the queue:$ kubectl get workloads | grep gpu-pod
pod-gpu-pod-357b8 default gpu True True 4sExample jobs with JobSet
examples/kubernetes/ has four example jobs, written as JobSets queued in Kueue. submit is a small helper: it fills in your uid, gid and home, gives the run a unique name, and with --wait collects the logs into <name>.out.$ cd examples/kubernetes
$ ./submit --wait nvl8-hello.yaml
nvl8-hello-563447
$ cat nvl8-hello-563447.out
[pod/nvl8-hello-563447-rank-0-7-qqdvr/hello] rank 7 on sched-worker2 NVIDIA_VISIBLE_DEVICES=GPU-814804a5-291e-ba91-a4e9-01fb69ea739b: NVIDIA GB200, GPU-814804a5-291e-ba91-a4e9-01fb69ea739b, 1
…
[pod/nvl8-hello-563447-rank-0-6-m65hh/hello] rank 6 on sched-worker2 NVIDIA_VISIBLE_DEVICES=GPU-8147ef90-7f0c-fc1e-c070-d80c4a3d939f: NVIDIA GB200, GPU-8147ef90-7f0c-fc1e-c070-d80c4a3d939f, 1torchrun doing rendezvous on pod 0 through the JobSet’s DNS name:$ ./submit --wait ddp-train.yaml
ddp-train-784428
$ grep -E "world=|step |rank 0/" ddp-train-784428.out
[pod/ddp-train-784428-node-0-0-8rgvd/torchrun] world=8 params=537M batch/rank=64 width=8192
[pod/ddp-train-784428-node-0-0-8rgvd/torchrun] step 1 7.9 ms 65182 samples/s 26 TFLOP/s/GPU
[pod/ddp-train-784428-node-0-0-8rgvd/torchrun] step 10 4.3 ms 119891 samples/s 48 TFLOP/s/GPU
[pod/ddp-train-784428-node-0-0-8rgvd/torchrun] step 20 4.1 ms 125733 samples/s 51 TFLOP/s/GPU
[pod/ddp-train-784428-node-0-0-8rgvd/torchrun] step 30 4.0 ms 126661 samples/s 51 TFLOP/s/GPU
[pod/ddp-train-784428-node-0-0-8rgvd/torchrun] step 40 4.0 ms 128022 samples/s 52 TFLOP/s/GPU
[pod/ddp-train-784428-node-0-0-8rgvd/torchrun] step 50 4.1 ms 124470 samples/s 50 TFLOP/s/GPU
[pod/ddp-train-784428-node-0-0-8rgvd/torchrun] rank 0/8 on ddp-train-784428-node-0-0 cuda:0 (NVIDIA GB200) peak mem 7.1 GiBOperations
Queueing
ddp-long.yaml: a copy of ddp-train.yaml with --steps 60000 added to the training script’s arguments. Then submit nvl8-hello behind it. Kueue suspends the second JobSet and says why:$ ./submit ddp-long.yaml
ddp-long-479273
$ ./submit nvl8-hello.yaml
nvl8-hello-370393
$ kubectl get workloads
NAME QUEUE RESERVED IN ADMITTED FINISHED AGE
jobset-ddp-long-479273-f3281 gpu gpu True 59s
jobset-ddp-train-784428-cf108 gpu gpu True True 2m15s
jobset-nvl8-hello-370393-dc423 gpu False 9s
jobset-nvl8-hello-563447-13ea0 gpu gpu True True 2m26s
$ kubectl get workload jobset-nvl8-hello-370393-dc423 \
-o jsonpath='{.status.conditions[?(@.type=="QuotaReserved")].message}'
couldn't assign flavors to pod set rank: insufficient unused quota for nvidia.com/gpu in flavor gb200, 8 more needednvl8-hello is admitted and completes.Cordoning a tray
$ bin/kubectl cordon sched-worker2joe on the login node, submit nvl8-hello and ask Kueue why it waits:$ ./submit nvl8-hello.yaml
nvl8-hello-460341
$ kubectl get workload jobset-nvl8-hello-460341-daffc -o jsonpath='{.status.conditions[?(@.type=="QuotaReserved")].message}'
couldn't assign flavors to pod set rank: topology "nvl" allows to fit only 4 out of 8 pod(s)bin/kubectl uncordon sched-worker2 on the host, the JobSet is admitted and completes. You’ll see the same message again in Part 5, where splitting the NVLink domain has the same effect as cordoning.Monitoring
sched_* series that Slurm’s exporter feeds in Part 2 (GPUs allocated, GPUs per user, jobs and nodes by state), so the Grafana dashboards don’t need to know which scheduler is running. With a 60,000-step DDP run holding all 8 GPUs and nvl8-hello queued behind it:# GPUs allocated
sched_gpus_alloc
8
# GPUs per user
sched_user_gpus
{namespace="joe", user="joe"} 8
# jobs that haven't completed
sched_jobs{state!="COMPLETED"}
RUNNING 1, PENDING 1
# nodes by state
sched_nodes
READY 2
# GPU utilisation per tray (4 GPUs Ă— ~88 %)
sum by (instance) (nvidia_smi_utilization_gpu_ratio)
3.52, 3.52
# processes on GPUs
sum by (instance) (nvidia_smi_compute_apps)
4 per trayLab overview dashboard

Scheduler & NVLink fabric dashboard
PENDING, so the queue is visible next to the allocation. In the Jobs by state panel, the DDP job is running (blue), and nvl8-hello is pending (yellow) from the moment it’s submitted until the GPUs free up. The panel is stacked, so the top line at 2 is both jobs together:
On the trays
$ bin/ssh sched-worker1 nvidia-smi --query-gpu=index,utilization.gpu,memory.used,power.draw,temperature.gpu --format=csv,noheader
0, 87 %, 7850 MiB, 890.25 W, 70
1, 87 %, 7850 MiB, 887.85 W, 70
…
$ bin/ssh sched-worker1 nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv,noheader
22749, /shared/venv/bin/python, 7338 MiB
…
$ bin/kubectl -n joe exec ddp-long-479273-node-0-0-5pbc9 -- nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv,noheader
16, /shared/venv/bin/python, 7338 MiB
…Next in the series