DRA#
Core API resources and allocation flow of Kubernetes Dynamic Resource Allocation (resource.k8s.io/v1).
With the legacy Device Plugin API (v1beta1), kubelet only advertised integer counts (eg. nvidia.com/gpu: 2), so attribute-based selection or sub-device capacity slicing (cores, memory) required custom Admission Webhooks and Scheduler Extenders. DRA exposes hardware attributes and capacity as core Kubernetes API objects scheduled directly by kube-scheduler.
API Resources#
| Resource | Scope | Created by | Role |
|---|---|---|---|
ResourceSlice | Cluster | Node DRA driver (DaemonSet) | Publishes per-node physical/allocatable devices (spec.devices), driver name (spec.driver), attributes, and capacity |
DeviceClass | Cluster | Cluster administrator | Selects a class of devices using CEL expressions (spec.selectors) |
ResourceClaim | Namespace | Workload user | Requests a DeviceClass, optional CEL filters, and capacity (cores, memory) |
ResourceClaimTemplate | Namespace | Workload user | Template used to dynamically create one ResourceClaim per Pod in Deployment or StatefulSet workloads |
apiVersion: resource.k8s.io/v1
kind: DeviceClass
metadata:
name: hami-core-gpu.project-hami.io
spec:
selectors:
- cel:
expression: "device.driver == 'hami-core-gpu.project-hami.io' && device.attributes['hami-core-gpu.project-hami.io'].type == 'hami-gpu'"
---
apiVersion: resource.k8s.io/v1
kind: ResourceClaim
metadata:
name: gpu-claim
spec:
devices:
requests:
- name: gpu
exactly:
deviceClassName: hami-core-gpu.project-hami.io
capacity:
requests:
cores: 30
memory: 4Gi
---
apiVersion: v1
kind: Pod
metadata:
name: gpu-pod
spec:
containers:
- name: app
image: ubuntu:24.04
resources:
claims:
- name: gpu
resourceClaims:
- name: gpu
resourceClaimName: gpu-claimReference Direction and Scheduling Flow#
Neither Pod nor ResourceClaim names a ResourceSlice directly. kube-scheduler reads both sides and binds them.
Pod ──▶ ResourceClaim ──▶ DeviceClass DRA Driver (DaemonSet) ──▶ ResourceSlice
│ │ │
└───────┬────────┘ │
▼ ▼
kube-scheduler ◀──── Evaluates CEL selectors and capacity across ResourceSlices
│
▼
Writes selected (driver, pool, device) into ResourceClaim.status.allocation- Per-node
ResourceSlicepublication: A DRA driverDaemonSeton each GPU node (eg. k8s-dra-driver) discovers local hardware and publishes aResourceSliceforspec.nodeName.spec.driver: Unique domain name of thekubeletDRA plugin managing these devices (eg.hami-core-gpu.project-hami.io). Used both inDeviceClassCEL filters and for routingkubeletgRPC socket calls.spec.devices: Slice of individual devices offered on the node, each carryingname,attributes(uuid,productName, etc.), partitionablecapacity(cores,memory), andallowMultipleAllocations.
- Scheduling and allocation:
kube-schedulerevaluatesDeviceClassandResourceClaimCEL expressions and remainingcapacityagainst allResourceSliceobjects, recording the chosen(driver, pool, device)tuple inResourceClaim.status.allocation. - CDI injection: Once the Pod is bound to the node,
kubeletcallsNodePrepareResourceson the plugin matchingspec.driver. The plugin writes a CDI spec mounting/dev/nvidia*, hostlibcuda.so, and limit environment variables into the container runtime. See GPU Driver and Runtime for howlibcuda.soandnvidia.kointeract inside the container.