@@ -9,13 +9,16 @@ weight: 65
9
9
10
10
<!-- overview -->
11
11
12
- {{< feature-state for_k8s_version="v1.27" state="alpha " >}}
12
+ {{< feature-state feature_gate_name="DynamicResourceAllocation " >}}
13
13
14
14
Dynamic resource allocation is an API for requesting and sharing resources
15
15
between pods and containers inside a pod. It is a generalization of the
16
16
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
19
22
initialization.
20
23
21
24
## {{% heading "prerequisites" %}}
@@ -56,11 +59,39 @@ PodSchedulingContext
56
59
to coordinate pod scheduling when ResourceClaims need to be allocated
57
60
for a Pod.
58
61
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
+
59
77
Parameters for ResourceClass and ResourceClaim are stored in separate objects,
60
78
typically using the type defined by a {{< glossary_tooltip
61
79
term_id="CustomResourceDefinition" text="CRD" >}} that was created when
62
80
installing a resource driver.
63
81
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
+
64
95
The ` core/v1 ` ` PodSpec ` defines ResourceClaims that are needed for a Pod in a
65
96
` resourceClaims ` field. Entries in that list reference either a ResourceClaim
66
97
or a ResourceClaimTemplate. When referencing a ResourceClaim, all Pods using
@@ -129,8 +160,11 @@ spec:
129
160
130
161
## Scheduling
131
162
163
+ ### Without structured parameters
164
+
132
165
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
134
168
dynamic resources are available in a cluster or how they could be split up to
135
169
satisfy the requirements of a specific ResourceClaim. Resource drivers are
136
170
responsible for that. They mark ResourceClaims as "allocated" once resources
@@ -172,6 +206,27 @@ ResourceClaims, and thus scheduling the next pod gets delayed.
172
206
173
207
{{< /note >}}
174
208
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.
175
230
176
231
## Monitoring resources
177
232
@@ -193,7 +248,13 @@ was not enabled in the scheduler at the time when the Pod got scheduled
193
248
detects this and tries to make the Pod runnable by triggering allocation and/or
194
249
reserving the required ResourceClaims.
195
250
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
197
258
blocks normal resources (RAM, CPU) that then cannot be used for other Pods
198
259
while the Pod is stuck. To make a Pod run on a specific node while still going
199
260
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.
255
316
# # {{% heading "whatsnext" %}}
256
317
257
318
- 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