Skip to content

Commit 0d1aa27

Browse files
authored
Merge pull request #45287 from pohly/dra-kubernetes-1.30
DRA in Kubernetes 1.30: adds structured parameters
2 parents 60c74ff + f4972cb commit 0d1aa27

File tree

1 file changed

+68
-6
lines changed

1 file changed

+68
-6
lines changed

content/en/docs/concepts/scheduling-eviction/dynamic-resource-allocation.md

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ weight: 65
99

1010
<!-- overview -->
1111

12-
{{< feature-state for_k8s_version="v1.27" state="alpha" >}}
12+
{{< feature-state feature_gate_name="DynamicResourceAllocation" >}}
1313

1414
Dynamic resource allocation is an API for requesting and sharing resources
1515
between pods and containers inside a pod. It is a generalization of the
1616
persistent volumes API for generic resources. Third-party resource drivers are
17-
responsible for tracking and allocating resources. Different kinds of
18-
resources support arbitrary parameters for defining requirements and
17+
responsible for tracking and allocating resources, with additional support
18+
provided by Kubernetes via _structured parameters_ (introduced in Kubernetes 1.30).
19+
When a driver uses structured parameters, Kubernetes handles scheduling
20+
and resource allocation without having to communicate with the driver.
21+
Different kinds of resources support arbitrary parameters for defining requirements and
1922
initialization.
2023

2124
## {{% heading "prerequisites" %}}
@@ -56,11 +59,39 @@ PodSchedulingContext
5659
to coordinate pod scheduling when ResourceClaims need to be allocated
5760
for a Pod.
5861

62+
ResourceSlice
63+
: Used with structured parameters to publish information about resources
64+
that are available in the cluster.
65+
66+
ResourceClaimParameters
67+
: Contain the parameters for a ResourceClaim which influence scheduling,
68+
in a format that is understood by Kubernetes (the "structured parameter
69+
model"). Additional parameters may be embedded in an opaque
70+
extension, for use by the vendor driver when setting up the underlying
71+
resource.
72+
73+
ResourceClassParameters
74+
: Similar to ResourceClaimParameters, the ResourceClassParameters provides
75+
a type for ResourceClass parameters which is understood by Kubernetes.
76+
5977
Parameters for ResourceClass and ResourceClaim are stored in separate objects,
6078
typically using the type defined by a {{< glossary_tooltip
6179
term_id="CustomResourceDefinition" text="CRD" >}} that was created when
6280
installing a resource driver.
6381

82+
The developer of a resource driver decides whether they want to handle these
83+
parameters in their own external controller or instead rely on Kubernetes to
84+
handle them through the use of structured parameters. A
85+
custom controller provides more flexibility, but cluster autoscaling is not
86+
going to work reliably for node-local resources. Structured parameters enable
87+
cluster autoscaling, but might not satisfy all use-cases.
88+
89+
When a driver uses structured parameters, it is still possible to let the
90+
end-user specify parameters with vendor-specific CRDs. When doing so, the
91+
driver needs to translate those
92+
custom parameters into the in-tree types. Alternatively, a driver may also
93+
document how to use the in-tree types directly.
94+
6495
The `core/v1` `PodSpec` defines ResourceClaims that are needed for a Pod in a
6596
`resourceClaims` field. Entries in that list reference either a ResourceClaim
6697
or a ResourceClaimTemplate. When referencing a ResourceClaim, all Pods using
@@ -129,8 +160,11 @@ spec:
129160
130161
## Scheduling
131162
163+
### Without structured parameters
164+
132165
In contrast to native resources (CPU, RAM) and extended resources (managed by a
133-
device plugin, advertised by kubelet), the scheduler has no knowledge of what
166+
device plugin, advertised by kubelet), without structured parameters
167+
the scheduler has no knowledge of what
134168
dynamic resources are available in a cluster or how they could be split up to
135169
satisfy the requirements of a specific ResourceClaim. Resource drivers are
136170
responsible for that. They mark ResourceClaims as "allocated" once resources
@@ -172,6 +206,27 @@ ResourceClaims, and thus scheduling the next pod gets delayed.
172206
173207
{{< /note >}}
174208
209+
### With structured parameters
210+
211+
When a driver uses structured parameters, the scheduler takes over the
212+
responsibility of allocating resources to a ResourceClaim whenever a pod needs
213+
them. It does so by retrieving the full list of available resources from
214+
ResourceSlice objects, tracking which of those resources have already been
215+
allocated to existing ResourceClaims, and then selecting from those resources
216+
that remain. The exact resources selected are subject to the constraints
217+
provided in any ResourceClaimParameters or ResourceClassParameters associated
218+
with the ResourceClaim.
219+
220+
The chosen resource is recorded in the ResourceClaim status together with any
221+
vendor-specific parameters, so when a pod is about to start on a node, the
222+
resource driver on the node has all the information it needs to prepare the
223+
resource.
224+
225+
By using structured parameters, the scheduler is able to reach a decision
226+
without communicating with any DRA resource drivers. It is also able to
227+
schedule multiple pods quickly by keeping information about ResourceClaim
228+
allocations in memory and writing this information to the ResourceClaim objects
229+
in the background while concurrently binding the pod to a node.
175230
176231
## Monitoring resources
177232
@@ -193,7 +248,13 @@ was not enabled in the scheduler at the time when the Pod got scheduled
193248
detects this and tries to make the Pod runnable by triggering allocation and/or
194249
reserving the required ResourceClaims.
195250

196-
However, it is better to avoid this because a Pod that is assigned to a node
251+
{{< note >}}
252+
253+
This only works with resource drivers that don't use structured parameters.
254+
255+
{{< /note >}}
256+
257+
It is better to avoid bypassing the scheduler because a Pod that is assigned to a node
197258
blocks normal resources (RAM, CPU) that then cannot be used for other Pods
198259
while the Pod is stuck. To make a Pod run on a specific node while still going
199260
through the normal scheduling flow, create the Pod with a node selector that
@@ -255,4 +316,5 @@ be installed. Please refer to the driver's documentation for details.
255316
## {{% heading "whatsnext" %}}
256317

257318
- For more information on the design, see the
258-
[Dynamic Resource Allocation KEP](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/3063-dynamic-resource-allocation/README.md).
319+
[Dynamic Resource Allocation KEP](https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/3063-dynamic-resource-allocation/README.md)
320+
and the [Structured Parameters KEP](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/4381-dra-structured-parameters).

0 commit comments

Comments
 (0)