Kubernetes AI Workloads: Latest Release Guide
In this article
The latest Kubernetes release introduces built-in support for AI workloads through enhanced GPU scheduling, dynamic resource allocation, and improved node topology management. This guide walks you through enabling these features, deploying an AI workload, and avoiding common pitfalls. You'll need a Kubernetes cluster (v1.31+ recommended) with GPU nodes and kubectl access.
What You'll Need
- A Kubernetes cluster (v1.31 or later) with at least one GPU node (NVIDIA, AMD, or Intel)
- kubectl configured to access the cluster
- NVIDIA device plugin (if using NVIDIA GPUs) or equivalent for other vendors
- Helm (optional, for easier deployment of AI operators)
- Basic understanding of Kubernetes Pod specs and YAML
Step-by-Step
- Verify your cluster version and GPU support. Run
kubectl versionto confirm the server version is at least 1.31. Check GPU availability withkubectl get nodes -o wideand look for thenvidia.com/gpuresource (or similar) in the capacity section. If not present, install the vendor-specific device plugin. - Enable the Dynamic Resource Allocation (DRA) feature gate. DRA is the new mechanism for managing specialized hardware like GPUs. On most managed clusters (EKS, AKS, GKE), it's already enabled. For self-managed clusters, add
--feature-gates=DynamicResourceAllocation=trueto the kubelet, kube-apiserver, and kube-scheduler startup flags. Then restart the components. - Define a ResourceClass for your GPU. Create a YAML file (e.g.,
gpu-class.yaml) that declares the resource class. For NVIDIA GPUs, it looks like:apiVersion: resource.k8s.io/v1alpha3 kind: ResourceClass metadata: name: nvidia-gpu spec: driverName: gpu.resource.nvidia.com
Apply it withkubectl apply -f gpu-class.yaml. - Deploy an AI workload using DRA. Instead of the old
nvidia.com/gpulimit, you now reference the ResourceClass in your Pod spec. Example:apiVersion: v1 kind: Pod metadata: name: ai-inference spec: containers: - name: inference image: tensorflow/serving:latest resources: claims: - name: gpu resourceClaims: - name: gpu resourceClassName: nvidia-gpuApply it withkubectl apply -f ai-pod.yaml. - Verify the GPU is allocated. Run
kubectl describe pod ai-inferenceand look for the resource claim status. You should see the GPU device listed as allocated. Also check the node withkubectl describe node <node-name>to see the allocated resources. - Use node topology for multi-GPU workloads. For distributed training, the new release supports NUMA-aware scheduling. Add a
topologyRequestto your ResourceClass to request GPUs on the same NUMA node. Example:spec: topologyRequest: <NUMA-node-id>
This ensures lower latency for inter-GPU communication. - Monitor GPU utilization with the new metrics. The kubelet now exposes GPU metrics via the /metrics endpoint. Use
kubectl top nodesor set up Prometheus scraping to see GPU utilization. For real-time monitoring, install the NVIDIA DCGM exporter.
Common Mistakes
- Forgetting to enable DRA on all components. If you only enable it on the scheduler, pods will fail with an unsupported feature error. Make sure kubelet and apiserver have the flag too.
- Using the old GPU resource limit. The
nvidia.com/gpulimit still works, but it doesn't support the new features like NUMA awareness. Mixing both can cause scheduling conflicts. - Not updating the device plugin. The DRA driver is separate from the classic device plugin. Ensure you have the DRA driver installed (e.g., NVIDIA's k8s-dra-driver) and that it matches your Kubernetes version.
- Ignoring node labels. DRA relies on node labels to know which nodes have which resources. Make sure your GPU nodes have the correct labels (e.g.,
nvidia.com/gpu.present=true). - Assuming all GPUs are the same. The ResourceClass can specify a model, but if you don't, the scheduler picks any GPU. For model-specific workloads, add a selector in the ResourceClass.
Tips
- Start with a simple test pod. Before running a full AI training job, deploy a small container that just queries the GPU (e.g.,
nvidia-smi) to verify the allocation works. - Use the
resource.k8s.ioAPI group. The DRA API is in alpha, but the group is stable. Always check the API version in your YAML; it may change. - Leverage the scheduler's new features. The latest scheduler can co-schedule pods that share a GPU (MIG mode). Look for the
resourceClaimssharing policy in your Pod spec. - Set resource quotas. DRA supports quotas on resource claims. Create a ResourceQuota in your namespace to limit GPU usage per team.
- Keep your cluster up to date. DRA is evolving rapidly. Upgrade to the latest patch release to get bug fixes and performance improvements.
Troubleshooting
Pod stays Pending. Check the events with kubectl describe pod. Common causes: no node with the required GPU, or the DRA driver is not running. Verify the driver pod is running in the kube-system namespace.
Resource claim not satisfied. Run kubectl get resourceclaims to see the status. If it says 'not satisfied', check the node's resource capacity and labels. Also ensure the ResourceClass exists.
GPU not visible inside container. This usually means the device plugin isn't mounting the device correctly. Check the driver logs and ensure the container has the necessary environment variables (e.g., NVIDIA_VISIBLE_DEVICES).
Performance is poor. If you're using multiple GPUs, check NUMA topology. Use kubectl describe node to see the topology zone. If GPUs are on different NUMA nodes, adjust the topologyRequest.
If nothing works: Restart the kubelet on the GPU node and the scheduler. Then re-apply the resource claims. If the problem persists, check the Kubernetes issue tracker for known bugs with your version.
Frequently Asked Questions
Do I need to change my existing AI workloads?
No, you can still use the traditional nvidia.com/gpu resource limit. DRA is optional, but it gives you more control over GPU allocation and topology.
Can I use DRA with AMD or Intel GPUs?
Yes, as long as the vendor provides a DRA driver. AMD and Intel have released drivers for their GPUs. Check their documentation for installation.
Is DRA production-ready?
DRA is still alpha, but it's stable enough for testing. For production, you may want to stick with the classic device plugin until DRA reaches beta.
How do I request a specific GPU model?
Add a selector in your ResourceClass spec, like selector:
matchLabels:
gpu-model: A100. Then label your nodes accordingly.
Can I share a GPU between multiple pods?
Yes, with MIG (Multi-Instance GPU) on NVIDIA A100 and newer. Set the sharing field in your ResourceClass to time-slicing or mig.
What happens if a GPU node fails?
Pods using that GPU will be rescheduled to another node with available GPU resources, if any. If not, they stay pending until a node becomes available.