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#

ResourceScopeCreated byRole
ResourceSliceClusterNode DRA driver (DaemonSet)Publishes per-node physical/allocatable devices (spec.devices), driver name (spec.driver), attributes, and capacity
DeviceClassClusterCluster administratorSelects a class of devices using CEL expressions (spec.selectors)
ResourceClaimNamespaceWorkload userRequests a DeviceClass, optional CEL filters, and capacity (cores, memory)
ResourceClaimTemplateNamespaceWorkload userTemplate 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-claim

Reference 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
  1. Per-node ResourceSlice publication: A DRA driver DaemonSet on each GPU node (eg. k8s-dra-driver) discovers local hardware and publishes a ResourceSlice for spec.nodeName.
    • spec.driver: Unique domain name of the kubelet DRA plugin managing these devices (eg. hami-core-gpu.project-hami.io). Used both in DeviceClass CEL filters and for routing kubelet gRPC socket calls.
    • spec.devices: Slice of individual devices offered on the node, each carrying name, attributes (uuid, productName, etc.), partitionable capacity (cores, memory), and allowMultipleAllocations.
  2. Scheduling and allocation: kube-scheduler evaluates DeviceClass and ResourceClaim CEL expressions and remaining capacity against all ResourceSlice objects, recording the chosen (driver, pool, device) tuple in ResourceClaim.status.allocation.
  3. CDI injection: Once the Pod is bound to the node, kubelet calls NodePrepareResources on the plugin matching spec.driver. The plugin writes a CDI spec mounting /dev/nvidia*, host libcuda.so, and limit environment variables into the container runtime. See GPU Driver and Runtime for how libcuda.so and nvidia.ko interact inside the container.