Lab 4: GPU Slicing with Dynamic Resource Allocation
The HAMi DRA driver is young and moving fast. This lab installs the exact DaemonSet manifests that were verified live on a Tesla T4 cluster (driver projecthami/k8s-dra-driver:v0.1.0). The driver repository has since added a Helm chart for the same v0.1.0 driver (in-repo at chart/hami-dra-driver, with a nvidiaDriverRoot value covering GPU Operator clusters); this lab will switch to the chart once that path has been verified. The consumable capacity feature also remains behind a Kubernetes feature gate.
In Lab 3 you sliced a GPU using HAMi's extended resources (nvidia.com/gpumem, nvidia.com/gpucores). This lab achieves the same outcome through Dynamic Resource Allocation (DRA), the Kubernetes-native device API that went GA in v1.34. Instead of opaque resource names, Pods request devices through ResourceClaims with structured, schema-validated capacity requests.
Why DRA Matters
| Extended resources (Lab 3) | DRA (this lab) | |
|---|---|---|
| API | nvidia.com/gpumem: 4000 in resource limits | ResourceClaim with capacity.requests: {memory: 4Gi, cores: 30} |
| Scheduling | HAMi scheduler extender + webhook | Native kube-scheduler DRA plugin |
| Device inventory | Node annotation written by the device plugin | ResourceSlice API objects with typed attributes |
| Device selection | Annotations such as nvidia.com/use-gputype | CEL expressions over device attributes |
| Validation | None (any number accepted at admission) | requestPolicy with min/max/step enforced by the API server |
The HAMi DRA driver implements the DRA Consumable Capacity feature: multiple Pods draw capacity from one device, with the scheduler doing the accounting.
Prerequisites
- A cluster from Lab 1 on Kubernetes v1.34 or newer, with HAMi and GPU Operator installed
- The manifests from
tutorials/labs/examples/04-hami-dra/
Lab Overview
Step 1: Enable the DRAConsumableCapacity Feature Gate
DRA itself is GA in v1.34, but consumable capacity (multiple Pods drawing from one device's capacity pool) requires the DRAConsumableCapacity feature gate on the control plane components and the kubelet. Run enable-dra-feature-gates.sh as root:
for f in kube-apiserver kube-scheduler kube-controller-manager; do
sed -i "/ - $f/a\\ - --feature-gates=DRAConsumableCapacity=true" /etc/kubernetes/manifests/$f.yaml
done
cat >> /var/lib/kubelet/config.yaml <<EOF
featureGates:
DRAConsumableCapacity: true
EOF
systemctl restart kubelet
Editing a static Pod manifest under
/etc/kubernetes/manifests/makes kubelet restart that component automatically. The API server drops for around 20 seconds; wait untilkubectl get nodesresponds again.
Verify the DRA API group is served:
kubectl api-resources --api-group=resource.k8s.io
NAME SHORTNAMES APIVERSION NAMESPACED KIND
deviceclasses resource.k8s.io/v1 false DeviceClass
resourceclaims resource.k8s.io/v1 true ResourceClaim
resourceclaimtemplates resource.k8s.io/v1 true ResourceClaimTemplate
resourceslices resource.k8s.io/v1 false ResourceSlice
Step 2: Configure the Container Runtime
The DRA driver selects devices via volume mounts rather than the NVIDIA_VISIBLE_DEVICES env var, which requires one extra NVIDIA Container Runtime option. With the GPU Operator managing the toolkit, set it through Helm (the operator rewrites the runtime config and restarts containerd for you):
RELEASE=$(helm list -n gpu-operator -o json | python3 -c "import json,sys; print(json.load(sys.stdin)[0]['name'])")
helm upgrade ${RELEASE} nvidia/gpu-operator -n gpu-operator --reuse-values \
--set-json 'toolkit.env=[{"name":"ACCEPT_NVIDIA_VISIBLE_DEVICES_AS_VOLUME_MOUNTS","value":"true"},{"name":"CONTAINERD_SET_AS_DEFAULT","value":"true"}]' \
--version=v25.3.0
Verify after the toolkit Pod restarts:
grep default_runtime_name /etc/containerd/config.toml
grep accept-nvidia-visible-devices-as-volume-mounts /usr/local/nvidia/toolkit/.config/nvidia-container-runtime/config.toml
default_runtime_name = "nvidia"
accept-nvidia-visible-devices-as-volume-mounts = true
Step 3: Install the HAMi DRA Driver
The driver runs as a kubelet plugin DaemonSet. Two manifests: RBAC, then the DaemonSet.
kubectl apply -f tutorials/labs/examples/04-hami-dra/rbac.yaml
kubectl apply -f tutorials/labs/examples/04-hami-dra/ds-gpu-operator.yaml
kubectl get pods -n hami-dra-driver
NAME READY STATUS RESTARTS AGE
hami-dra-driver-kubelet-plugin-r4jtt 1/1 Running 0 31s
ds-gpu-operator.yamlis the upstream DaemonSet with one adjustment:NVIDIA_DRIVER_ROOTand thedriver-roothostPath point at/run/nvidia/driver, because the GPU Operator keeps the driver inside a container rather than on the host. If your driver is installed directly on the host, use the upstreamds.yamlunchanged.