kubernetes/kubernetes
Dynamic Resource Allocation (DRA)
DRA is the workflow that lets pods request named, opaque devices — GPUs, FPGAs, SR-IOV virtual functions, RDMA NICs, encryption accelerators. It generalizes the older "device plugin" model into something the scheduler understands.
The pieces
graph TD
User -->|kubectl apply<br/>ResourceClaim + Pod| API[kube-apiserver]
DRADriverCM[DRA driver kubelet plugin] -->|publish ResourceSlice| API
API -->|watch| Sched[kube-scheduler<br/>dynamicresources plugin]
Sched -->|allocate ResourceClaim| API
API -->|watch| Kubelet
Kubelet -->|gRPC NodePrepareResources| DRADriverCM
DRADriverCM --> Container[Container]Resources involved
- DeviceClass (
resource.k8s.io/v1) — vendor-defined class with selectors. - ResourceClaim — a request for a specific device or set of devices, scoped to a Pod.
- ResourceClaimTemplate — a stamp from which per-pod claims are generated.
- ResourceSlice — published by DRA driver kubelet plugins, lists the devices each node has.
API types live in staging/src/k8s.io/api/resource/v1/. Validation in pkg/apis/resource/validation/. Registry in pkg/registry/resource/.
The scheduler plugin
pkg/scheduler/framework/plugins/dynamicresources/ plugs into:
- PreFilter — read the pod's claims, look up matching ResourceSlices, pre-compute candidates per node.
- Filter — eliminate nodes that have no matching slice.
- Reserve — write a tentative allocation to the claim.
- PreBind — confirm the allocation is still valid; the kubelet plugin will see this on its next watch.
- PostBind / Unreserve — finalize or roll back.
The plugin uses an internal ResourceSliceTracker (staging/src/k8s.io/dynamic-resource-allocation/resourceslice/tracker/) to maintain a fast in-memory view of every advertised device.
The kubelet plugin
pkg/kubelet/cm/dra/ is the kubelet-side integrator. It:
- Watches its node's pods + claims.
- For each pod with claims, calls
NodePrepareResourceson the DRA driver's gRPC socket. - Receives a
ContainerInforesponse describing how to inject the device into the container (CDI device specs, env vars, mounts). - Hands those instructions to the runtime via the CRI
LinuxContainerResourcesextensions. - On pod termination, calls
NodeUnprepareResources.
DRA driver kubelet plugins register through the same pkg/kubelet/pluginmanager/ socket-discovery mechanism as CSI drivers and device plugins.
Controller-manager components
- resource-claim controller (
pkg/controller/resourceclaim/) — creates per-pod ResourceClaims from ResourceClaimTemplate and binds them to Pods. - device-taint-eviction (
pkg/controller/devicetainteviction/) — DRA equivalent of NoExecute taint eviction. If a device gets ataint, pods that reserved it are evicted. - resource-pool-status (
pkg/controller/resourcepoolstatusrequest/) — reconciles resource-pool status.
Library
staging/src/k8s.io/dynamic-resource-allocation/ is the shared library used by:
- The scheduler plugin (for snapshotting and CEL evaluation).
- DRA driver authors (for the gRPC server boilerplate, CDI device building, and resource-slice publishing).
- The kubelet integration.
CEL in DRA
DeviceClass selectors are written in CEL:
selectors:
- cel:
expression: device.attributes["pci.vendor_id"] == "10de"CEL evaluation is in staging/src/k8s.io/dynamic-resource-allocation/cel/. The error path is significant — recent commits in this area focus on producing actionable error messages when CEL refers to a non-existent attribute (e.g. the dra-cel-no-such-key-error enhancement landed in late April 2026).
Status: alpha → beta → GA
Different DRA features advance at different rates:
- Core ResourceClaim / ResourceSlice flow: beta.
- Per-claim CEL selectors: beta.
- Cross-claim quotas (
ResourceQuotaintegration): alpha. - Allocator-backed claims (where the API server picks a device): alpha.
Track via pkg/features/kube_features.go for the gates DynamicResourceAllocation, DRAResourceClaimDeviceStatus, and friends.
Key source files
| File | Purpose |
|---|---|
staging/src/k8s.io/api/resource/v1/types.go |
API types |
staging/src/k8s.io/dynamic-resource-allocation/resourceslice/tracker/ |
Slice cache |
staging/src/k8s.io/dynamic-resource-allocation/cel/ |
CEL evaluator |
pkg/scheduler/framework/plugins/dynamicresources/ |
Scheduler plugin |
pkg/kubelet/cm/dra/manager.go |
Kubelet integration |
pkg/controller/resourceclaim/resource_claim_controller.go |
Claim allocation controller |
pkg/registry/resource/resourceclaim/storage/storage.go |
REST registry |
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.