@@ -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 -->
@@ -204,7 +213,8 @@ the `.spec.nodeName` field and to use a node selector instead.
204
213
205
214
{{< feature-state feature_gate_name="DRAAdminAccess" >}}
206
215
207
- A ResourceClaim with admin access grants access to devices which are in use and
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
208
218
may enable additional permissions when making the device available in a
209
219
container :
210
220
@@ -227,9 +237,75 @@ automatically when creating such a ResourceClaim.
227
237
228
238
Admin access is a privileged mode which should not be made available to normal
229
239
users in a multi-tenant cluster. Cluster administrators can restrict usage of
230
- this features by installing a validating admission policy similar to
231
- [the in-tree example](https://github.com/kubernetes/kubernetes/blob/33ea278/test/e2e/dra/test-driver/deploy/example/admin-access-policy.yaml)
232
- when enabling this feature.
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
+ ` ` `
233
309
234
310
# # ResourceClaim Device Status
235
311
@@ -291,7 +367,7 @@ be installed. Please refer to the driver's documentation for details.
291
367
292
368
# ## Enabling admin access
293
369
294
- Admin access is an *alpha feature* and only enabled when the
370
+ [ Admin access](#admin-access) is an *alpha feature* and only enabled when the
295
371
` DRAAdminAccess` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
296
372
is enabled in the kube-apiserver and kube-scheduler.
297
373
0 commit comments