Kubernetes for AI clusters
The control plane, pods and deployments, how GPUs become schedulable resources, and why Kubernetes is the natural home for inference.
- Describe AI cluster orchestration and job scheduling essentials.
- Identify the key considerations for virtualizing accelerated infrastructure.
Kubernetes is the open-source container orchestrator, hosted by the CNCF. You describe the desired state ("run three replicas of this inference service, each with one GPU") and Kubernetes keeps reality matching it: placing containers, restarting failures, scaling, routing traffic.
01The components
| Component | Role |
|---|---|
| kube-apiserver | The front door; every action goes through its API |
| etcd | Consistent key-value store holding all cluster state |
| kube-scheduler | Chooses a node for each new pod based on requested resources and constraints |
| kube-controller-manager | Runs control loops that move actual state toward desired state |
| kubelet (each node) | Makes sure the pod’s containers are running and healthy |
| kube-proxy (each node) | Maintains network rules for Services |
| Container runtime | Runs containers (containerd, CRI-O) |
02Objects you will hear about
- Pod: the smallest deployable unit, one or more containers sharing a network namespace and storage.
- Deployment: manages a set of identical, stateless pods through ReplicaSets, with rolling updates and rollback. Ideal for inference services.
- Service: a stable address and load balancer in front of pods.
- Job: runs pods to completion (batch work).
- Horizontal Pod Autoscaler: adds or removes replicas based on load.
- Namespace, ResourceQuota: divide a cluster between teams and cap their usage.
03GPUs in Kubernetes
Kubernetes knows nothing about GPUs by itself. A device plugin registers them with the kubelet as an extended resource (nvidia.com/gpu). Pods request them in resources.limits. Extended resources are whole integers and cannot be overcommitted or shared between containers, so to share GPUs you use MIG slices (exposed as separate resources), time-slicing, or a GPU-aware scheduler such as Run:ai. The GPU Operator installs the device plugin, driver, toolkit and DCGM Exporter for you; GPU Feature Discovery labels nodes by GPU model so pods can target them.
apiVersion: apps/v1
kind: Deployment
metadata: { name: llm-api }
spec:
replicas: 3
selector: { matchLabels: { app: llm-api } }
template:
metadata: { labels: { app: llm-api } }
spec:
containers:
- name: nim
image: nvcr.io/nim/meta/llama-3.1-8b-instruct:latest
resources:
limits: { nvidia.com/gpu: 1 }
04Kubernetes vs Slurm
Kubernetes shines at always-on services: autoscaling, self-healing, rolling updates. That makes it the usual platform for inference. Its default scheduler places pods one by one and does not natively do gang scheduling (start all pieces of a multi-node job together), so large distributed training often runs on Slurm, or on Kubernetes with an add-on scheduler such as Run:ai. See Job scheduling for the comparison table.
✦Key terms: flip the cards
- Control plane: apiserver, etcd, scheduler, controller-manager; node: kubelet, kube-proxy, runtime.
- GPUs via device plugin and GPU Operator; request nvidia.com/gpu in limits.
- Kubernetes suits inference services (autoscaling, self-healing); large training often uses Slurm or gang-aware schedulers.
- The default Kubernetes scheduler does not do gang scheduling.
- Requesting a GPU in requests only is not how extended resources work; use limits.
?Quick quiz
1. Which component stores all Kubernetes cluster state?
Why: etcd is the cluster’s key-value store.
2. Which object best fits an always-on, replicated inference API?
Why: Deployments manage replicated, stateless services.
3. How does Kubernetes learn a node has GPUs?
Why: The NVIDIA device plugin advertises GPUs.
4. Why is Kubernetes a strong fit for inference?
Why: Service-oriented features suit always-on inference.
Score: 0 / 4
This lesson explains the reading in plain language and adds the exam context around it. Read the original too: it is short, and seeing the vendor wording helps on exam day.