Skip to content

Commit 5dab30d

Browse files
committed
KEP-4601: alpha docs
1 parent 8b08791 commit 5dab30d

File tree

6 files changed

+95
-2
lines changed

6 files changed

+95
-2
lines changed

content/en/docs/reference/access-authn-authz/node.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ Read operations:
2727
* secrets, configmaps, persistent volume claims and persistent volumes related
2828
to pods bound to the kubelet's node
2929

30+
{{< feature-state feature_gate_name="AuthorizeNodeWithSelectors" >}}
31+
32+
When the `AuthorizeNodeWithSelectors` feature is enabled
33+
(along with the pre-requisite `AuthorizeWithSelectors` feature),
34+
kubelets are only allowed to read their own Node objects,
35+
and are only allowed to read pods bound to their node.
36+
3037
Write operations:
3138

3239
* nodes and node status (enable the `NodeRestriction` admission plugin to limit

content/en/docs/reference/access-authn-authz/validating-admission-policy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ variables as well as some other useful variables:
283283
The value is null if the incoming object is cluster-scoped.
284284
- `authorizer` - A CEL Authorizer. May be used to perform authorization checks for the principal
285285
(authenticated user) of the request. See
286+
[AuthzSelectors](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#AuthzSelectors) and
286287
[Authz](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz) in the Kubernetes CEL library
287288
documentation for more details.
288289
- `authorizer.requestResource` - A shortcut for an authorization check configured with the request

content/en/docs/reference/access-authn-authz/webhook.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,55 @@ Access to non-resource paths are sent as:
164164
}
165165
```
166166

167+
{{< feature-state feature_gate_name="AuthorizeWithSelectors" >}}
168+
169+
With the `AuthorizeWithSelectors` feature enabled, field and label selectors in the request
170+
are passed to the authorization webhook. The webhook can make authorization decisions
171+
informed by the scoped field and label selectors, if it wishes.
172+
173+
The [SubjectAccessReview API documentation](/docs/reference/kubernetes-api/authorization-resources/subject-access-review-v1/)
174+
gives guidelines for how these fields should be interpreted and handled by authorization webhooks,
175+
specifically using the parsed requirements rather than the raw selector strings,
176+
and how to handle unrecognized operators safely.
177+
178+
```json
179+
{
180+
"apiVersion": "authorization.k8s.io/v1beta1",
181+
"kind": "SubjectAccessReview",
182+
"spec": {
183+
"resourceAttributes": {
184+
"verb": "list",
185+
"group": "",
186+
"resource": "pods",
187+
"fieldSelector": {
188+
"requirements": [
189+
{"key":"spec.nodeName", "operator":"In", "values":["mynode"]}
190+
]
191+
},
192+
"labelSelector": {
193+
"requirements": [
194+
{"key":"example.com/mykey", "operator":"In", "values":["myvalue"]}
195+
]
196+
}
197+
},
198+
"user": "jane",
199+
"group": [
200+
"group1",
201+
"group2"
202+
]
203+
}
204+
}
205+
```
206+
167207
Non-resource paths include: `/api`, `/apis`, `/metrics`,
168208
`/logs`, `/debug`, `/healthz`, `/livez`, `/openapi/v2`, `/readyz`, and
169209
`/version.` Clients require access to `/api`, `/api/*`, `/apis`, `/apis/*`,
170210
and `/version` to discover what resources and versions are present on the server.
171211
Access to other non-resource paths can be disallowed without restricting access
172212
to the REST api.
173213

174-
For further documentation refer to the authorization.v1beta1 API objects and
175-
[webhook.go](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go).
214+
For further information, refer to the
215+
[SubjectAccessReview API documentation](/docs/reference/kubernetes-api/authorization-resources/subject-access-review-v1/)
216+
and
217+
[webhook.go implementation](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go).
176218

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: AuthorizeNodeWithSelectors
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.31"
12+
---
13+
Make the [Node authorizer](/docs/reference/access-authn-authz/node/) use fine-grained selector authorization.
14+
Requires `AuthorizeWithSelectors` to be enabled.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: AuthorizeWithSelectors
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.31"
12+
---
13+
Allows authorization to use field and label selectors.
14+
Enables `fieldSelector` and `labelSelector` fields in the [SubjectAccessReview API](/docs/reference/kubernetes-api/authorization-resources/subject-access-review-v1/),
15+
passes field and label selector information to [authorization webhooks](/docs/reference/access-authn-authz/webhook/),
16+
enables `fieldSelector` and `labelSelector` functions in the [authorizer CEL library](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#AuthzSelectors),
17+
and enables checking `fieldSelector` and `labelSelector` fields in [authorization webhook `matchConditions`](/docs/reference/access-authn-authz/authorization/#using-configuration-file-for-authorization).

content/en/docs/reference/using-api/cel.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,19 @@ To perform an authorization check for a service account:
200200
| `authorizer.serviceAccount('default', 'myserviceaccount').resource('deployments').check('delete').allowed()` | Checks if the service account is authorized to delete deployments. |
201201
{{< /table >}}
202202

203+
{{< feature-state state="alpha" for_k8s_version="v1.31" >}}
204+
205+
With the alpha `AuthorizeWithSelectors` feature enabled, field and label selectors can be added to authorization checks.
206+
207+
{{< table caption="Examples of CEL expressions using selector authorization functions" >}}
208+
| CEL Expression | Purpose |
209+
|--------------------------------------------------------------------------------------------------------------|------------------------------------------------|
210+
| `authorizer.group('').resource('pods').fieldSelector('spec.nodeName=mynode').check('list').allowed()` | Returns true if the principal (user or service account) is allowed to list pods with the field selector `spec.nodeName=mynode`. |
211+
| `authorizer.group('').resource('pods').labelSelector('example.com/mylabel=myvalue').check('list').allowed()` | Returns true if the principal (user or service account) is allowed to list pods with the label selector `example.com/mylabel=myvalue`. |
212+
{{< /table >}}
213+
203214
See the [Kubernetes Authz library](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz)
215+
and [Kubernetes AuthzSelectors library](https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#AuthzSelectors)
204216
godoc for more information.
205217

206218
### Kubernetes quantity library

0 commit comments

Comments
 (0)