@@ -5,6 +5,15 @@ reviewers:
5
5
title : Dynamic Resource Allocation
6
6
content_type : concept
7
7
weight : 65
8
+ api_metadata :
9
+ - apiVersion : " resource.k8s.io/v1beta1"
10
+ kind : " ResourceClaim"
11
+ - apiVersion : " resource.k8s.io/v1beta1"
12
+ kind : " ResourceClaimTemplate"
13
+ - apiVersion : " resource.k8s.io/v1beta1"
14
+ kind : " DeviceClass"
15
+ - apiVersion : " resource.k8s.io/v1beta1"
16
+ kind : " ResourceSlice"
8
17
---
9
18
10
19
<!-- overview -->
@@ -39,7 +48,7 @@ v{{< skew currentVersion>}}, check the documentation for that version of Kuberne
39
48
40
49
## API
41
50
42
- The ` resource.k8s.io/v1alpha3 `
51
+ The ` resource.k8s.io/v1beta1 `
43
52
{{< glossary_tooltip text="API group" term_id="api-group" >}} provides these types:
44
53
45
54
ResourceClaim
@@ -85,15 +94,15 @@ Here is an example for a fictional resource driver. Two ResourceClaim objects
85
94
will get created for this Pod and each container gets access to one of them.
86
95
87
96
``` yaml
88
- apiVersion : resource.k8s.io/v1alpha3
97
+ apiVersion : resource.k8s.io/v1beta1
89
98
kind : DeviceClass
90
99
name : resource.example.com
91
100
spec :
92
101
selectors :
93
102
- cel :
94
103
expression : device.driver == "resource-driver.example.com"
95
104
---
96
- apiVersion : resource.k8s.io/v1alpha2
105
+ apiVersion : resource.k8s.io/v1beta1
97
106
kind : ResourceClaimTemplate
98
107
metadata :
99
108
name : large-black-cat-claim-template
@@ -200,6 +209,104 @@ spec:
200
209
You may also be able to mutate the incoming Pod, at admission time, to unset
201
210
the `.spec.nodeName` field and to use a node selector instead.
202
211
212
+ # # Admin access
213
+
214
+ {{< feature-state feature_gate_name="DRAAdminAccess" >}}
215
+
216
+ You can mark a request in a ResourceClaim or ResourceClaimTemplate as having privileged features.
217
+ A request with admin access grants access to devices which are in use and
218
+ may enable additional permissions when making the device available in a
219
+ container :
220
+
221
+ ` ` ` yaml
222
+ apiVersion: resource.k8s.io/v1beta1
223
+ kind: ResourceClaimTemplate
224
+ metadata:
225
+ name: large-black-cat-claim-template
226
+ spec:
227
+ spec:
228
+ devices:
229
+ requests:
230
+ - name: req-0
231
+ deviceClassName: resource.example.com
232
+ adminAccess: true
233
+ ` ` `
234
+
235
+ If this feature is disabled, the `adminAccess` field will be removed
236
+ automatically when creating such a ResourceClaim.
237
+
238
+ Admin access is a privileged mode which should not be made available to normal
239
+ users in a multi-tenant cluster. Cluster administrators can restrict usage of
240
+ this feature by installing a validating admission policy similar to the following
241
+ example. Cluster administrators need to adapt at least the names and replace
242
+ " dra.example.com" .
243
+
244
+ ` ` ` yaml
245
+ # Permission to use admin access is granted only in namespaces which have the
246
+ # "admin-access.dra.example.com" label. Other ways of making that decision are
247
+ # also possible.
248
+
249
+ apiVersion: admissionregistration.k8s.io/v1
250
+ kind: ValidatingAdmissionPolicy
251
+ metadata:
252
+ name: resourceclaim-policy.dra.example.com
253
+ spec:
254
+ failurePolicy: Fail
255
+ matchConstraints:
256
+ resourceRules:
257
+ - apiGroups: ["resource.k8s.io"]
258
+ apiVersions: ["v1alpha3", "v1beta1"]
259
+ operations: ["CREATE", "UPDATE"]
260
+ resources: ["resourceclaims"]
261
+ validations:
262
+ - expression: '! object.spec.devices.requests.exists(e, has(e.adminAccess) && e.adminAccess)'
263
+ reason: Forbidden
264
+ messageExpression: '"admin access to devices not enabled"'
265
+ ---
266
+ apiVersion: admissionregistration.k8s.io/v1
267
+ kind: ValidatingAdmissionPolicyBinding
268
+ metadata:
269
+ name: resourceclaim-binding.dra.example.com
270
+ spec:
271
+ policyName: resourceclaim-policy.dra.example.com
272
+ validationActions: [Deny]
273
+ matchResources:
274
+ namespaceSelector:
275
+ matchExpressions:
276
+ - key: admin-access.dra.example.com
277
+ operator: DoesNotExist
278
+ ---
279
+ apiVersion: admissionregistration.k8s.io/v1
280
+ kind: ValidatingAdmissionPolicy
281
+ metadata:
282
+ name: resourceclaimtemplate-policy.dra.example.com
283
+ spec:
284
+ failurePolicy: Fail
285
+ matchConstraints:
286
+ resourceRules:
287
+ - apiGroups: ["resource.k8s.io"]
288
+ apiVersions: ["v1alpha3", "v1beta1"]
289
+ operations: ["CREATE", "UPDATE"]
290
+ resources: ["resourceclaimtemplates"]
291
+ validations:
292
+ - expression: '! object.spec.spec.devices.requests.exists(e, has(e.adminAccess) && e.adminAccess)'
293
+ reason: Forbidden
294
+ messageExpression: '"admin access to devices not enabled"'
295
+ ---
296
+ apiVersion: admissionregistration.k8s.io/v1
297
+ kind: ValidatingAdmissionPolicyBinding
298
+ metadata:
299
+ name: resourceclaimtemplate-binding.dra.example.com
300
+ spec:
301
+ policyName: resourceclaimtemplate-policy.dra.example.com
302
+ validationActions: [Deny]
303
+ matchResources:
304
+ namespaceSelector:
305
+ matchExpressions:
306
+ - key: admin-access.dra.example.com
307
+ operator: DoesNotExist
308
+ ` ` `
309
+
203
310
# # ResourceClaim Device Status
204
311
205
312
{{< feature-state feature_gate_name="DRAResourceClaimDeviceStatus" >}}
@@ -219,9 +326,9 @@ existing ResourceClaim where the `status.devices` field is set.
219
326
220
327
# # Enabling dynamic resource allocation
221
328
222
- Dynamic resource allocation is an *alpha feature* and only enabled when the
329
+ Dynamic resource allocation is a *beta feature* which is off by default and only enabled when the
223
330
` DynamicResourceAllocation` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
224
- and the `resource.k8s.io/v1alpha3 ` {{< glossary_tooltip text="API group" term_id="api-group" >}}
331
+ and the `resource.k8s.io/v1beta1 ` {{< glossary_tooltip text="API group" term_id="api-group" >}}
225
332
are enabled. For details on that, see the `--feature-gates` and `--runtime-config`
226
333
[kube-apiserver parameters](/docs/reference/command-line-tools-reference/kube-apiserver/).
227
334
kube-scheduler, kube-controller-manager and kubelet also need the feature gate.
@@ -258,6 +365,12 @@ include it.
258
365
In addition to enabling the feature in the cluster, a resource driver also has to
259
366
be installed. Please refer to the driver's documentation for details.
260
367
368
+ # ## Enabling admin access
369
+
370
+ [Admin access](#admin-access) is an *alpha feature* and only enabled when the
371
+ ` DRAAdminAccess` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
372
+ is enabled in the kube-apiserver and kube-scheduler.
373
+
261
374
# ## Enabling Device Status
262
375
263
376
[ResourceClaim Device Status](#resourceclaim-device-status) is an *alpha feature*
0 commit comments