GPU Operator: How to Deploy AI Workloads on Kubernetes
Learn how GPU Operator automates GPU infrastructure management for Kubernetes workloads, from driver installation and resource discovery to monitoring. This article covers deployment steps, readiness checks, session-aware updates and rollbacks for LLM inference, and capacity planning across GPU nodes, instances, and conversations.
1. Why AI Workloads Need Dedicated GPU Management
Cloud-native platforms have established practices for deploying, updating, and autoscaling stateless applications. The growth of large language model inference, however, challenges one of their underlying assumptions: that a Pod can be replaced at any time without disrupting application state.
An inference instance serving long-running conversations holds important state in GPU memory. Its key-value (KV) cache contains computed representations of conversation context for active sessions. Terminating the instance destroys that cached state. Without a way to restore or reconstruct it, ongoing conversations may lose continuity—a more disruptive failure than a brief increase in latency.
GPU nodes also introduce operational complexity beyond that of ordinary compute nodes. Host drivers must be compatible with the GPU hardware and the container runtime environment. Containers need access to GPU device files and user-space libraries. Metrics such as GPU memory consumption, utilization, and temperature require dedicated collection components.
Maintaining this infrastructure through manual scripts becomes increasingly difficult as a cluster grows. GPU Operator addresses the infrastructure side of the problem by declaratively automating driver installation, container runtime configuration, device plugin deployment, and monitoring. This makes GPU nodes manageable within the same orchestration framework as other cluster resources.
2. Core Components of GPU Operator
A typical GPU Operator deployment coordinates four main capabilities:
- Driver lifecycle management: Node labels identify GPU-equipped nodes, allowing the Operator to install and manage the appropriate drivers. This reduces version drift caused by configuring nodes individually.
- Container runtime integration: GPU device files and user-space libraries are made available inside containers so that application processes can access GPU hardware.
- Device plugin: The plugin advertises GPU resources to Kubernetes, allowing Pods to request them and the scheduler to assign workloads to suitable nodes. This is the layer that makes GPUs declaratively schedulable resources.
- Monitoring and observability: Components deployed as DaemonSets collect metrics such as utilization, GPU memory usage, and temperature from GPU nodes. These metrics support alerting, capacity planning, and troubleshooting.
A workload can declare its GPU requirement as follows:
apiVersion: apps/v1kind: Deploymentmetadata:name: llm-inferencespec:replicas: 3selector:matchLabels:app: llm-inferencetemplate:metadata:labels:app: llm-inferencespec:containers:- name: inference-serverimage: <inference-service-image>resources:limits:nvidia.com/gpu: 1 # GPU resource advertised by the device pluginreadinessProbe:httpGet:path: /healthport: 8080
Once GPU Operator is deployed and GPU resources are available, Pods can request GPUs through resource limits. The scheduler then places them on nodes with sufficient available GPU resources, without manual device assignment.
3. Deployment: From Unconfigured Nodes to Schedulable GPUs
Step 1: Prepare and Label Nodes
Install the base operating system on the bare-metal or virtual machine nodes, then ensure that GPU nodes have the labels used by the Operator to identify them.
The Operator uses this node information to manage driver installation and validation, reducing the need to maintain driver consistency manually across individual machines.
Step 2: Verify GPU Resource Reporting
Use the cluster’s resource inspection commands to confirm that GPU resources are being advertised correctly.
If a node reports no available GPUs, common causes include:
- The driver has not finished loading.
- The device plugin is not functioning correctly.
- Required node labels are missing.
Check these areas in that order to narrow down the issue.
Step 3: Run AI Workloads
Submit inference services and training tasks as standard Kubernetes workloads.
For distributed training, use a job controller that supports distributed execution so that tasks can be coordinated across GPUs on multiple nodes.
For inference, pay particular attention to readiness probes. Loading a model may take several minutes. Configure probe timing accordingly, and ensure that the readiness endpoint does not report success before the model is ready to serve requests.
4. Safe Updates and Rollbacks for Stateful Inference
Model releases are becoming more frequent. Base models may evolve monthly, fine-tuned versions weekly, and domain adapters daily. Teams therefore need both an efficient release process and a reliable way to roll back problematic changes.
For inference services that retain conversation state in KV caches, use a connection-draining rollout rather than immediately replacing existing instances.
Start the new version behind a separate Service or backend pool. Once its readiness checks pass, use the traffic gateway to gradually route new requests to it. Stop assigning new sessions to the old version, but allow existing conversations to continue there until they finish or reach a maximum grace period.
The flow is:
New Pods start→ Readiness checks pass→ Gateway gradually routes new requests to the new version→ Old Pods serve existing sessions only→ Existing conversations finish or reach the grace-period limit→ Old Pods terminate gracefully(optionally persisting or migrating KV caches)
At the orchestration layer, configure an appropriate termination grace period for the old Pods. Combine it with a preStop hook to coordinate connection shutdown or migration before the container exits.
For applications with strict conversation-continuity requirements, serializing KV caches to external storage and restoring them on replacement instances may be worth exploring. This is an application-level capability, however, and its I/O overhead and implementation complexity must be weighed carefully.
Rollbacks should follow the same session-preservation principles. During an emergency rollback, first stop sending new traffic to the problematic version and protect its existing sessions. Then gradually scale down that version. Deleting Pods immediately risks disrupting large numbers of active conversations.
5. Capacity Management and Observability
GPUs are expensive and often scarce. Build observability at three levels:
- Node level: Continuously collect GPU utilization, memory usage, temperature, and power consumption. Use these metrics to identify idle or overloaded nodes and inform scaling and workload-placement decisions.
- Instance level: Monitor inference queue depth, time to first token, and throughput to detect performance degradation.
- Session level: Track the number of active conversations and the distribution of context lengths. Use this information to estimate KV-cache memory requirements and reduce the risk of GPU out-of-memory failures during peaks in long conversations.
For capacity planning, consider separating training and inference into different node pools. Training jobs often occupy GPUs for extended periods, while inference services need predictable, low-latency responses. Running them together can create resource contention.
On cloud container platforms that support GPU node-pool autoscaling, expand capacity during demand peaks and reduce it when demand subsides to limit steady-state infrastructure costs.
Conclusion
GPU Operator turns GPUs from hardware that requires specialized, node-by-node maintenance into resources that can be managed declaratively and scheduled through Kubernetes.
Reliable AI inference requires an additional layer of engineering: respecting the state held by active sessions. Updates should drain existing conversations, rollbacks should preserve session continuity, and observability should extend beyond node utilization to GPU memory and conversation context.
Combining automated GPU infrastructure management with session-aware workload operations makes it possible to scale AI services while retaining both deployment agility and reliability.
