Pidoku

Kubernetes for GPUs

Module 21 Lesson 21.c 1h 30m Difficulty 4/5

Prerequisites 3.c, 3.j, 9.h, 19.e


Before you start: words you need#

WordPlain meaning
PodThe smallest thing Kubernetes runs: one or more containers that share a network and volumes and land on the same machine (node).
kubeletThe agent on each node that starts pods and hands them devices.
Device pluginThe original way to expose GPUs: a node agent that advertises a count (nvidia.com/gpu: 8).
DRADynamic Resource Allocation: the newer Kubernetes API where pods describe the devices they need (“two GPUs with at least 80 GB”) through ResourceClaims.
GPU OperatorNVIDIA’s Kubernetes operator that installs and upgrades the GPU driver, container toolkit, device plugin or DRA driver, and monitoring on every GPU node.
QoS classKubernetes’ label for how strictly a pod’s CPU and memory are guaranteed. Guaranteed means requests equal limits.
NUMA nodeOne CPU socket with its own memory and PCIe devices. Crossing to the other socket is slower (3.c).
Gang schedulingPlacing all the pods of a group at once, or none of them.

1. What is it?#

Most inference platforms run on Kubernetes. Kubernetes was built for CPU services, so getting a GPU into a pod, on the right CPUs and memory, alongside the right peer GPUs and network cards, takes several pieces working together. Most GPU clusters get at least one of them subtly wrong, and each mistake costs latency or throughput without any error message.

This lesson covers the node stack, the two ways GPUs are allocated (device plugin and DRA), the pod settings that matter for inference, multi-GPU and multi-node placement, and the 2026 status of each piece. Deploying one vLLM server (probes, shutdown, the basic manifest) is in 19.e and is not repeated here.

Facts checked on 12 November 2026: Kubernetes 1.37 (26 August 2026), GPU Operator 26.7.2, NVIDIA device plugin v0.20.1, DRA Driver for NVIDIA GPUs v0.5.1, LeaderWorkerSet v1.0.0.


2. Why does it matter?#

WRONG SETTING                         WHAT YOU SEE
Burstable QoS (requests ≠ limits)     CPU throttling → 100 ms latency spikes, p99 doubles (3.j)
GPUs on one socket, CPUs on the other host-to-GPU copies 1.5–2x slower
8 GPUs split across two NVLink groups all-reduce over PCIe → TP=8 decode several times slower (14.m)
64 MB /dev/shm (the default)          NCCL "Bus error", crashes at start
thread count from the node, not quota hundreds of threads fighting for 16 cores
multi-node pods placed one at a time  half an instance holds GPUs forever, never ready

None of these produce a clear error. The model works, just slower or less reliably, and the cause is invisible from the application.


3. Simple analogy#

Renting workshop space. The landlord (Kubernetes) can give you “eight workbenches”. What you actually need is eight benches next to each other (NVLink), on the floor where your tools are stored (NUMA), with a guaranteed electrician who will not be shared with the tenant next door (dedicated CPUs), and a store room big enough for your materials (/dev/shm). If you only ask for “eight benches”, you may get them on three floors.

DRA is the landlord learning to read a detailed request instead of a number.


4. Tiny example: the same request, two ways#

Device plugin: ask for a count.

YAML
resources:
  limits:
    nvidia.com/gpu: 2        # whole GPUs; which ones is up to the kubelet

DRA: describe the devices, then refer to the claim.

YAML
apiVersion: resource.k8s.io/v1
kind: ResourceClaimTemplate
metadata:
  name: two-large-gpus
spec:
  spec:
    devices:
      requests:
        - name: gpus
          exactly:
            deviceClassName: gpu.nvidia.com
            count: 2
            selectors:
              - cel:
                  expression: device.capacity['gpu.nvidia.com'].memory.isGreaterThan(quantity("70Gi"))
---
# in the pod spec
spec:
  resourceClaims:
    - name: gpus
      resourceClaimTemplateName: two-large-gpus
  containers:
    - name: vllm
      resources:
        claims:
          - name: gpus

The DRA version says what the workload needs. The scheduler finds devices that match, records the choice in the claim, and the driver prepares exactly those devices on the node.


5. Technical explanation#

The node stack#

flowchart TB
  HW["GPU on the node"] --> DRV["NVIDIA driver + container toolkit<br/>installed by the GPU Operator"]
  DRV --> ADV["Device plugin (a count)<br/>or DRA driver (ResourceSlices)"]
  ADV --> API["API server: node capacity / ResourceSlices"]
  POD["Pod: count or ResourceClaim"] --> SCH["Scheduler picks node and devices"]
  API --> SCH
  SCH --> KUB["Kubelet prepares the devices"]
  KUB --> CTR["Container starts with devices<br/>and driver libraries injected (CDI)"]

  class HW,DRV compute
  class ADV,API,SCH,KUB queue
  class POD neutral
  class CTR memory

The GPU Operator installs and upgrades, on every GPU node: the driver (or uses the one in the node image), the container toolkit, the device plugin or DRA driver, GPU Feature Discovery (which labels nodes with nvidia.com/gpu.product and friends), DCGM and its exporter for metrics (21.l), and the MIG manager (21.d). Since 25.10 it injects devices with CDI (Container Device Interface, a standard file that tells the runtime which device nodes and libraries to add) by default. In 26.7 (August 2026) it added a GPUCluster resource that deploys the DRA driver instead of the device plugin; a cluster uses either GPUCluster or the older ClusterPolicy, not both.

Device plugin or DRA in November 2026#

Device pluginDRA
RequestA count: nvidia.com/gpu: 8A ResourceClaim with selectors and constraints
Kubernetes statusStable for yearsCore API GA since 1.34 (Aug 2025)
Choosing which GPUsKubelet, with Topology Manager hintsScheduler, using published attributes (memory, product, PCIe root, NUMA node)
SharingTime-slicing or MPS via plugin config; MIG as fixed resource namesClaims can be shared; MIG and partitionable devices; consumable capacity (beta gate)
HealthUnhealthy GPU removed from the countDevice taints (GA in 1.37) mark one GPU unschedulable without touching the node
NVIDIA supportk8s-device-plugin v0.20.1, the production defaultDRA Driver for NVIDIA GPUs v0.5.1, now in kubernetes-sigs

What changed in the last three Kubernetes releases:

1.34 (Aug 2025)  DRA core API (resource.k8s.io/v1) GA
1.36 (Apr 2026)  prioritized lists GA ("this kind of GPU, else that kind");
                 partitionable devices, device taints, binding conditions, health status: beta
                 OCI image volumes GA (21.b)
1.37 (Aug 2026)  extended-resource support GA: a pod asking for nvidia.com/gpu: 1
                 can be satisfied by a DRA driver, which eases migration;
                 device taints and tolerations GA; standard numaNode attribute GA;
                 ResourceClaims for whole workloads: beta, off by default

The honest 2026 position for NVIDIA GPUs. The NVIDIA DRA driver has two halves. Its ComputeDomain half (secure multi-node NVLink across a GB200 or GB300 NVL72 rack) is officially supported and is how multi-node NVLink jobs are wired on Kubernetes. Its GPU allocation half is still described by the project as not yet officially supported, and its kubelet plugin is off by default in the Helm chart. So most production fleets still allocate GPUs with the device plugin, use DRA ComputeDomains on NVL72 racks, and pilot DRA GPU allocation on new clusters. Check the driver’s release notes before you move production allocation.

Whichever you run, allocation dashboards must count both: nvidia.com/gpu requests and allocated DRA devices. A dashboard that counts only one will misreport free capacity.

The four pod settings that are usually wrong#

(a) Guaranteed QoS and the static CPU manager.

YAML
resources:
  requests: {cpu: "32", memory: "256Gi", nvidia.com/gpu: 2}   # whole-number CPUs,
  limits:   {cpu: "32", memory: "256Gi", nvidia.com/gpu: 2}   # requests == limits
kubelet: --cpu-manager-policy=static  --reserved-cpus=0-3

BUYS YOU   exclusive cores (a cpuset): no CFS throttling, no neighbour on your cores,
           and the precondition for NUMA alignment
WITHOUT    CFS quota throttling → 100 ms stalls in the engine loop (3.j)

This is the most effective Kubernetes setting for inference latency, and it is off by default. The engine’s scheduler loop and tokenizer run on the CPU; a stalled CPU stalls the GPU (20.a).

(b) Topology Manager.

kubelet: --topology-manager-policy=single-numa-node  --topology-manager-scope=pod

Aligns the pod's CPUs, memory, GPUs and NICs on one NUMA node.
Without it: pinned host buffers on the wrong socket → 1.5–2x slower copies;
            GPUs and NIC on different sockets → RDMA crosses the CPU link.

Caveat: single-numa-node makes a pod unschedulable when no single NUMA node has enough.
        "restricted" or "best-effort" are softer, but you lose the guarantee.

With DRA, the same goal is expressed as a claim constraint: all requested devices must share one pcieRoot or numaNode attribute. That puts the alignment decision in the scheduler instead of the kubelet, which avoids pods that are scheduled to a node and then rejected there.

(c) /dev/shm.

YAML
volumes:
  - name: dshm
    emptyDir: {medium: Memory, sizeLimit: 16Gi}
# mounted at /dev/shm in the container

Containers default to 64 MB. NCCL’s shared-memory transport, multi-process engines (vLLM’s API server and engine core talk through shared memory) and PyTorch all use it.

(d) Thread counts from the quota.

YAML
env:
  - {name: OMP_NUM_THREADS, value: "8"}
  - {name: TOKENIZERS_PARALLELISM, value: "false"}   # if you parallelise per request

os.cpu_count() returns the node’s cores, not your quota (3.j). Libraries that trust it start far too many threads.

PROBLEM   on an 8-GPU HGX node every GPU reaches every other through NVSwitch, so any 2 are fine.
          On PCIe-only nodes (L40S, RTX PRO 6000) or nodes with two NVLink groups,
          "2 GPUs" may be two that only talk over PCIe through the CPU.

OPTIONS   1. ask for the whole node (8 of 8): simple, no waste if the model needs 8
          2. Topology Manager single-numa-node: aligns GPUs with a socket
          3. DRA constraint: matchAttribute on pcieRoot or numaNode
          4. a scheduler that understands topology (KAI Scheduler, Kueue's topology-aware
             scheduling, Volcano; 21.e)

VERIFY    inside the pod:  nvidia-smi topo -m   → GPU pairs show NV#, not SYS or NODE

Always verify inside the pod. The container sees a renumbered subset of the node’s GPUs.

Multi-node instances#

A model too big for one node (a 1T-parameter MoE, or wide expert parallelism) runs as a group of pods that must start, fail and restart together.

YAML
apiVersion: leaderworkerset.x-k8s.io/v1
kind: LeaderWorkerSet
metadata:
  name: big-moe
spec:
  replicas: 2                      # two independent instances
  leaderWorkerTemplate:
    size: 4                        # 4 pods (nodes) per instance
    restartPolicy: RecreateGroupOnPodRestart   # one pod fails → restart the group
    leaderTemplate:  {...}         # runs the API server and rank 0
    workerTemplate:  {...}         # 8 GPUs and RDMA NICs each
REQUIRED FOR MULTI-NODE
  □ a group controller: LeaderWorkerSet (v1.0, Oct 2026), or a framework operator
    such as Dynamo's Grove or llm-d's DisaggregatedSet (21.j)
  □ group restart: one pod failing must restart the instance (9.h)
  □ gang scheduling: Kueue, KAI Scheduler or Volcano today; the built-in Workload API
    and gang scheduling reached beta in Kubernetes 1.37 but are off by default
  □ topology: all pods in one rack or NVLink domain (DRA ComputeDomain on NVL72)
  □ RDMA NICs exposed (an RDMA device plugin or a DRA network driver such as DraNet)
    and GPUDirect RDMA verified
  □ a headless Service so ranks can find each other; NCCL told which interfaces to use

Without gang scheduling, a half-placed instance holds GPUs and never becomes ready. It looks like used capacity on every dashboard and serves nothing.

A complete inference pod, for reference#

YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: chat-general
spec:
  replicas: 6
  selector: {matchLabels: {app: chat-general}}
  template:
    metadata: {labels: {app: chat-general}}
    spec:
      nodeSelector:
        nvidia.com/gpu.product: NVIDIA-H100-80GB-HBM3
      tolerations:
        - {key: nvidia.com/gpu, operator: Exists, effect: NoSchedule}
      containers:
        - name: vllm
          image: vllm/vllm-openai:v0.32.0          # pin by digest in production
          args: ["--model", "/models/qwen3-32b-fp8",
                 "--tensor-parallel-size", "2",
                 "--max-model-len", "32768",
                 "--max-num-seqs", "128",
                 "--gpu-memory-utilization", "0.90",
                 "--enable-prefix-caching"]
          resources:
            requests: {cpu: "32", memory: "256Gi", nvidia.com/gpu: 2}
            limits:   {cpu: "32", memory: "256Gi", nvidia.com/gpu: 2}
          env:
            - {name: OMP_NUM_THREADS, value: "8"}
          volumeMounts:
            - {name: models, mountPath: /models, readOnly: true}
            - {name: dshm,   mountPath: /dev/shm}
          # startupProbe, readinessProbe, preStop drain: see 19.e
      terminationGracePeriodSeconds: 900           # ≥ p99 generation time (20.h)
      volumes:
        - name: models
          image: {reference: registry.internal/models/qwen3-32b-fp8:v1.5.0}  # image volume, 21.b
        - name: dshm
          emptyDir: {medium: Memory, sizeLimit: 16Gi}

Every line answers something earlier in the material. Tracing each one back is the first exercise.


6. Under the hood: what happens when a DRA pod is scheduled#

1. The DRA driver on each node publishes ResourceSlices: one entry per GPU (or MIG slice),
   with attributes (productName, architecture, uuid, pcieRoot, numaNode)
   and capacities (memory; for MIG also multiprocessors, copy engines).
2. A pod refers to a ResourceClaimTemplate; Kubernetes creates a ResourceClaim for it.
3. The scheduler evaluates the claim's CEL selectors and constraints against the slices,
   alongside CPU and memory, and picks a node AND specific devices.
4. It writes the allocation into the claim's status, then binds the pod.
5. The kubelet asks the driver to "prepare" the devices (create a MIG slice, set up MPS,
   join a ComputeDomain), and the runtime injects them through CDI.
6. When the pod ends, the driver "unprepares" them and the claim is freed.

The important change from the device plugin is step 3: the scheduler, not the kubelet, picks the devices, with full knowledge of their attributes. That is what makes topology constraints, fallbacks (“an H200, else two H100s”) and per-device health workable at cluster scale.


7. Performance implications#

  • Static CPU manager and Guaranteed QoS remove the 100 ms throttling stalls that dominate p99 on busy nodes. It is the cheapest large win in this lesson.
  • NUMA alignment matters most for workloads that move data across PCIe: KV offload to CPU memory (14.k), disaggregated KV transfer over RDMA (9.e), and frequent model loads.
  • GPU topology decides whether tensor parallelism runs over NVLink (hundreds of GB/s) or PCIe (tens of GB/s). On a PCIe-only node, a TP=2 pod across sockets can be slower than TP=1.
  • Image volumes and node caches turn model load from minutes to seconds (21.b, 20.g).

8. Production implications#

  • Use the GPU Operator rather than managing drivers by hand; upgrade it like any other critical component, one node pool at a time.
  • Guaranteed QoS with the static CPU manager on every latency-sensitive pod.
  • Align NUMA with the Topology Manager, or DRA constraints on new clusters.
  • Size /dev/shm (16 GB is a safe default) and set thread counts from the quota.
  • Use gang scheduling and group restart for anything that spans nodes.
  • Pilot DRA now on a new node pool: it is where Kubernetes GPU features are going, and 1.37’s extended-resource bridge lets old nvidia.com/gpu pod specs run on DRA-managed nodes.
  • Verify topology inside the pod after every node image or operator upgrade.
  • Count both device-plugin and DRA allocations in capacity dashboards (21.l).

9. Common mistakes#

  1. Burstable QoS (requests ≠ limits) on inference pods. CFS throttling and 100 ms spikes.
  2. CPU limits that are not whole cores. The static policy then does not give exclusive cores.
  3. Default 64 MB /dev/shm. NCCL and multi-process engines fail.
  4. Thread counts from nproc. Massive oversubscription.
  5. Multi-GPU pods across sockets or NVLink groups, never checked with nvidia-smi topo -m.
  6. No gang scheduling for multi-node. Partial placements leak GPUs.
  7. Pulling weights from object storage in every pod. Minutes of cold start (21.b).
  8. Assuming DRA GPU allocation is production-ready everywhere because the core API is GA. The API is stable; each vendor’s driver has its own status.
  9. Dashboards that count only nvidia.com/gpu on a cluster that also uses DRA.

10. Hands-on exercise#

  1. Audit a spec. Take a real GPU pod spec (yours or a public chart) and check it against section 8. How many items are missing?
  2. Show throttling. Run the same load with Burstable and Guaranteed QoS. Compare nr_throttled in the pod’s cpu.stat and the p99 inter-token latency.
  3. Check topology. Start a 2-GPU pod on a PCIe-only node and run nvidia-smi topo -m inside it. Fix the placement with the Topology Manager, then re-check.
  4. Try DRA in kind. Follow the DRA driver’s kind demo (or use a fake driver) and write a claim that asks for “one device with more than 40 GiB, else two with more than 20 GiB” using firstAvailable. Look at the resulting ResourceClaim status.
  5. Break the gang. Deploy a 4-pod LeaderWorkerSet on a cluster with room for only 3 pods, without and then with a gang scheduler. What holds GPUs in each case?

11. Interview questions#

  1. How does a GPU get from the node into a container, step by step?
  2. Compare the device plugin and DRA. What does DRA let the scheduler do that the device plugin cannot?
  3. What is the status of DRA for NVIDIA GPUs in late 2026, and how would you roll it out?
  4. Why does Guaranteed QoS with the static CPU manager matter for inference latency?
  5. What does the Topology Manager do, and when can single-numa-node hurt you?
  6. What does a multi-node deployment need that a single-node one does not?
  7. Your TP=2 pod is half as fast on one node pool as on another. What do you check first?

12. Further reading#

Checked on 12 November 2026.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in