Skip to content

Commit a27b158

Browse files
committed
address feedback
Signed-off-by: Rita Zhang <[email protected]>
1 parent 4515061 commit a27b158

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

content/en/blog/_posts/2024-04-xx-structured-authz-beta.md

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
layout: blog
3-
title: 'Multi-Webhook Authorization Made Easy'
3+
title: 'Multi-Webhook and Modular Authorization Made Easy'
44
date: 2024-04-nn
5-
slug: multi-webhook-authorization-made-easy
5+
slug: multi-webhook-and-modular-authorization-made-easy
66
---
77

88
**Authors:** [Rita Zhang](https://github.com/ritazh) (Microsoft), [Jordan
@@ -13,7 +13,7 @@ Capili](https://github.com/stealthybox) (VMware)
1313
# Enhancing Kubernetes Authorization with Multiple Webhooks and Structured Configuration
1414

1515
## Introduction
16-
Kubernetes continuous to evolve to meet the intricate requirements of system
16+
Kubernetes continues to evolve to meet the intricate requirements of system
1717
administrators and developers alike. A critical aspect of Kubernetes that
1818
ensures the security and integrity of the cluster is the API server
1919
authorization. Until recently, the configuration of the authorization chain in
@@ -24,24 +24,25 @@ define complex, fine-grained authorization policies. The latest Structured
2424
Authorization Configuration feature ([KEP-3221](https://kep.k8s.io/3221)) aims
2525
to revolutionize this aspect by introducing a more structured and versatile way
2626
to configure the authorization chain, focusing on enabling multiple webhooks and
27-
providing explicit control mechanisms such as the explicit Deny authorizer.
27+
providing explicit control mechanisms.
2828

2929
## The Need for Improvement
3030
Cluster administrators have long sought the ability to specify multiple
31-
authorization webhooks within the API Server handler chain. This need arises
32-
from the desire to create layered security policies, where requests can be
33-
validated against multiple criteria or sets of rules in a specific order. The
34-
previous limitations also made it difficult to declaratively configure the
31+
authorization webhooks within the API Server handler chain and have control over
32+
detailed behavior like timeout and failure policy for each webhook. This need
33+
arises from the desire to create layered security policies, where requests can
34+
be validated against multiple criteria or sets of rules in a specific order. The
35+
previous limitations also made it difficult to dynamically configure the
3536
authorizer chain, leaving no room to efficiently manage complex authorization
3637
scenarios.
3738

3839
The [Structured Authorization Configuration
3940
feature](/docs/reference/access-authn-authz/authorization/#configuring-the-api-server-using-an-authorization-config-file)
4041
addresses these limitations by introducing a configuration file format to
4142
configure Kubernetes API Server Authorization chain. This format allows
42-
specifying multiple webhooks in the authorization chain while all other types of
43-
authorizers should at most be specified once. Each webhook authorizer comes with
44-
its well-defined parameters, including timeout settings, failure policies, and
43+
specifying multiple webhooks in the authorization chain (all other authorization
44+
types are specified no more than once). Each webhook authorizer comes with its
45+
well-defined parameters, including timeout settings, failure policies, and
4546
conditions for invocation with [CEL](/docs/reference/using-api/cel/) rules to
4647
pre-filter requests before they are dispatched to webhooks, helping you to
4748
prevent unnecessary invocations. The configuration also supports automatic
@@ -158,17 +159,18 @@ order, and failure modes.
158159
159160
### Protecting Installed CRDs
160161
Ensuring the availability of Custom Resource Definitions (CRDs) at cluster
161-
startup has been a key demand, One of the blockers for having a controller
162+
startup has been a key demand. One of the blockers for having a controller
162163
reconciling those CRDs is to have a protection mechanism for them, which can be
163-
achieved through multiple Authorization Webhooks. This was not possible before.
164-
Now with the Structured Authorization Configuration feature, administrators can
165-
specify multiple webhooks offering a solution where RBAC falls short, especially
166-
in denying permissions to 'non-system' users for certain CRDs.
164+
achieved through multiple authorization webhooks. This was not possible before
165+
as specifying multiple authorization webhooks in the Kubernetes API Server
166+
authorization chain was simply not possible. Now with the Structured
167+
Authorization Configuration feature, administrators can specify multiple
168+
webhooks offering a solution where RBAC falls short, especially in denying
169+
permissions to 'non-system' users for certain CRDs.
167170
168171
Assuming the following for this scenario:
169-
- The "protected" CRDs are installed in the kube-system namespace.
170-
- They can only be modified by users in the group
171-
`system:serviceaccounts:kube-superuser`
172+
- The "protected" CRDs are installed.
173+
- They can only be modified by users in the group `admin`
172174

173175
```yaml
174176
apiVersion: apiserver.config.k8s.io/v1beta1
@@ -188,12 +190,11 @@ authorizers:
188190
matchConditions:
189191
# only send resource requests to the webhook
190192
- expression: has(request.resourceAttributes)
191-
# only intercept requests to kube-system
192-
- expression: request.resourceAttributes.namespace == 'kube-system'
193-
# don't intercept requests from kube-system service accounts
194-
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
195-
# only intercept update, delete or deletecollection requests
196-
- expression: request.resourceAttributes.verb in ['update', 'delete','deletecollection']
193+
# only intercept requests for CRDs
194+
- expression: request.resourceAttributes.resource.resource = "customresourcedefinitions"
195+
- expression: request.resourceAttributes.resource.group = ""
196+
# only intercept update, patch, delete, or deletecollection requests
197+
- expression: request.resourceAttributes.verb in ['update', 'patch', 'delete','deletecollection']
197198
- type: Node
198199
- type: RBAC
199200
```
@@ -212,8 +213,8 @@ consistent and predictable responses.
212213
apiVersion: apiserver.config.k8s.io/v1beta1
213214
kind: AuthorizationConfiguration
214215
authorizers:
215-
- name: system-crd-protector
216-
type: Webhook
216+
- type: Webhook
217+
name: system-crd-protector
217218
webhook:
218219
unauthorizedTTL: 30s
219220
timeout: 3s
@@ -226,10 +227,11 @@ authorizers:
226227
matchConditions:
227228
# only send resource requests to the webhook
228229
- expression: has(request.resourceAttributes)
229-
# only intercept requests to kube-system
230-
- expression: request.resourceAttributes.namespace == 'kube-system'
231-
# don't intercept requests from kube-system service accounts
232-
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
230+
# only intercept requests for CRDs
231+
- expression: request.resourceAttributes.resource.resource = "customresourcedefinitions"
232+
- expression: request.resourceAttributes.resource.group = ""
233+
# only intercept update, patch, delete, or deletecollection requests
234+
- expression: request.resourceAttributes.verb in ['update', 'patch', 'delete','deletecollection']
233235
- type: Node
234236
- type: RBAC
235237
- name: opa
@@ -255,7 +257,7 @@ authorizers:
255257
## What's next?
256258
For Kubernetes v1.31, we expect the feature to stay in beta while we get more
257259
feedback. Then once the feature is ready for GA, the feature flag will be
258-
removed.
260+
removed and the configuration file version will be promoted to v1.
259261

260262
You can learn more about this feature on the [structured authorization
261263
configuration](/docs/reference/access-authn-authz/authorization/#configuring-the-api-server-using-an-authorization-config-file)
@@ -270,7 +272,9 @@ for real world scenarios. To use this feature, you must specify the path to the
270272
authorization configuration using the `--authorization-config` command line
271273
argument. From Kubernetes 1.30, the feature is in beta and enabled by default.
272274
If you want to keep using command line flags instead of a configuration file,
273-
those will continue to work as-is.
275+
those will continue to work as-is. Specifying both `--authorization-config` and
276+
`--authorization-modes`/`--authorization-webhook-*` won't work. You need to drop
277+
the older flags from your kube-apiserver command.
274278

275279
The following kind Cluster configuration sets that command argument on the
276280
APIserver to load an AuthorizationConfiguration from a file
@@ -280,7 +284,7 @@ certificate files can also be put in the files directory.
280284
kind: Cluster
281285
apiVersion: kind.x-k8s.io/v1alpha4
282286
featureGates:
283-
StructuredAuthorizationConfiguration: true # only required for v1.29; enabled by default in v1.30
287+
StructuredAuthorizationConfiguration: true # enabled by default in v1.30
284288
kubeadmConfigPatches:
285289
- |
286290
kind: ClusterConfiguration

0 commit comments

Comments
 (0)