Skip to content

Commit 2131b01

Browse files
authored
Merge pull request #48330 from pohly/dra-1.32
DRA 1.32: beta
2 parents ee231f7 + 26b5da0 commit 2131b01

File tree

8 files changed

+3146
-5
lines changed

8 files changed

+3146
-5
lines changed

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

Lines changed: 118 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ reviewers:
55
title: Dynamic Resource Allocation
66
content_type: concept
77
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"
817
---
918

1019
<!-- overview -->
@@ -39,7 +48,7 @@ v{{< skew currentVersion>}}, check the documentation for that version of Kuberne
3948

4049
## API
4150

42-
The `resource.k8s.io/v1alpha3`
51+
The `resource.k8s.io/v1beta1`
4352
{{< glossary_tooltip text="API group" term_id="api-group" >}} provides these types:
4453

4554
ResourceClaim
@@ -85,15 +94,15 @@ Here is an example for a fictional resource driver. Two ResourceClaim objects
8594
will get created for this Pod and each container gets access to one of them.
8695

8796
```yaml
88-
apiVersion: resource.k8s.io/v1alpha3
97+
apiVersion: resource.k8s.io/v1beta1
8998
kind: DeviceClass
9099
name: resource.example.com
91100
spec:
92101
selectors:
93102
- cel:
94103
expression: device.driver == "resource-driver.example.com"
95104
---
96-
apiVersion: resource.k8s.io/v1alpha2
105+
apiVersion: resource.k8s.io/v1beta1
97106
kind: ResourceClaimTemplate
98107
metadata:
99108
name: large-black-cat-claim-template
@@ -200,6 +209,104 @@ spec:
200209
You may also be able to mutate the incoming Pod, at admission time, to unset
201210
the `.spec.nodeName` field and to use a node selector instead.
202211

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+
203310
## ResourceClaim Device Status
204311

205312
{{< feature-state feature_gate_name="DRAResourceClaimDeviceStatus" >}}
@@ -219,9 +326,9 @@ existing ResourceClaim where the `status.devices` field is set.
219326

220327
## Enabling dynamic resource allocation
221328

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
223330
`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" >}}
225332
are enabled. For details on that, see the `--feature-gates` and `--runtime-config`
226333
[kube-apiserver parameters](/docs/reference/command-line-tools-reference/kube-apiserver/).
227334
kube-scheduler, kube-controller-manager and kubelet also need the feature gate.
@@ -258,6 +365,12 @@ include it.
258365
In addition to enabling the feature in the cluster, a resource driver also has to
259366
be installed. Please refer to the driver's documentation for details.
260367

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+
261374
### Enabling Device Status
262375

263376
[ResourceClaim Device Status](#resourceclaim-device-status) is an *alpha feature*
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: DRAAdminAccess
3+
content_type: feature_gate
4+
_build:
5+
list: never
6+
render: false
7+
8+
stages:
9+
- stage: alpha
10+
defaultValue: false
11+
fromVersion: "1.32"
12+
---
13+
Enables support for requesting [admin access](/docs/concepts/scheduling-eviction/dynamic-resource-allocation/#admin-access)
14+
in a ResourceClaim. A ResourceClaim
15+
with admin access grants access to devices which are in use and may enable
16+
additional access permissions when making the device available in a container.
17+
18+
This feature gate has no effect unless you also enable the `DynamicResourceAllocation` feature gate.

content/en/docs/reference/command-line-tools-reference/feature-gates/dynamic-resource-allocation.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ stages:
99
- stage: alpha
1010
defaultValue: false
1111
fromVersion: "1.30"
12+
toVersion: "1.31"
13+
- stage: beta
14+
defaultValue: false
15+
fromVersion: "1.32"
16+
17+
# TODO: as soon as this is locked to "true" (= GA), comments about other DRA
18+
# feature gate(s) like "unless you also enable the `DynamicResourceAllocation` feature gate"
19+
# can be removed (for example, in dra-admin-access.md).
20+
1221
---
1322
Enables support for resources with custom parameters and a lifecycle
1423
that is independent of a Pod. Allocation of resources is handled

content/en/docs/reference/kubernetes-api/extend-resources/device-class-v1alpha3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ To update the reference content, please follow the
1919
[Contributing upstream](/docs/contribute/generate-ref-docs/contribute-upstream/)
2020
guide. You can file document formatting bugs against the
2121
[reference-docs](https://github.com/kubernetes-sigs/reference-docs/) project.
22+
23+
TODO: this file should be under "workload-resources".
2224
-->
2325

2426
`apiVersion: resource.k8s.io/v1alpha3`

0 commit comments

Comments
 (0)