Prerequisites
Before you start, you must have:- A CKS cluster with at least one x86 (amd64) GPU node. NVIDIA NIM containers require x86 architecture. This tutorial uses an L40 GPU, but any NVIDIA GPU with 16 GB or more of VRAM works.
- kubectl installed and connected to your cluster.
- An NVIDIA NGC account and API key. To generate an API key, sign in to NGC and go to your profile dropdown > Setup > API Keys.
Set your NGC API key
Export your NGC API key as an environment variable. The commands in this tutorial reference this variable when creating Kubernetes Secrets.Verify cluster access
Confirm thatkubectl can reach your cluster and that GPU nodes are available:
nvidia.com/gpu in its capacity:
Create NGC secrets
NIM containers are hosted on NVIDIA’s NGC registry (nvcr.io). To authenticate with NGC, you must create two Kubernetes Secrets: one to pull the container image, and one for the NIM runtime to download model weights.
Deploy the NIM
With authentication configured, deploy the NIM itself. Save the following manifest asnim-hello-world.yaml. This manifest defines a single-replica Deployment with one GPU and a ClusterIP Service that exposes the inference API on port 8000.
nim-hello-world.yaml
If your cluster uses a different GPU type, adjust the
nodeSelector to match. Use kubectl get nodes -o jsonpath='{.items[*].metadata.labels.gpu\.nvidia\.com/class}' to see available GPU classes.Wait for the NIM to become ready
The Deployment and Service exist, but the NIM container must download model weights before it can serve traffic. On first start, this can take several minutes depending on model size and network speed. To check Pod status, list the Pods with thenim-hello-world label:
If the Pod restarts during startup, the liveness probe might trigger before the model finishes loading. Increase
initialDelaySeconds on the liveness probe, or check logs with kubectl logs -n default -l app=nim-hello-world --tail=50.Query the NIM
Send a chat completion request to the NIM. The API is compatible with the OpenAI Chat Completions format. Because the Service type is ClusterIP, you can only reach the endpoint from within the cluster. The following command uses a temporary Pod to send the request:Clean up
When you’re done, remove the Deployment, Service, and Secrets so the GPU node and credentials are no longer in use.Next steps
Now that you have a working NIM deployment, explore these options:- Try a different model. Replace the image and model name in the manifest to deploy any NIM-supported model.
- Add autoscaling. See the Deploy vLLM for inference tutorial for patterns using KEDA and Prometheus-based autoscaling.
- Expose externally. Add an Ingress or LoadBalancer Service to serve inference requests from outside the cluster.