Skip to content

Commit 48620d7

Browse files
committed
KEP-3221: add blog post for beta
Signed-off-by: Rita Zhang <[email protected]>
1 parent 248f71f commit 48620d7

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
layout: blog
3+
title: 'Multi-Webhook Authorization Made Easy'
4+
date: 2024-04-nn
5+
slug: multi-webhook-authorization-made-easy
6+
---
7+
8+
**Authors:** [Rita Zhang](https://github.com/ritazh) (Microsoft), [Jordan
9+
Liggitt](https://github.com/liggitt) (Google), [Nabarun
10+
Pal](https://github.com/palnabarun) (VMware)
11+
12+
# Enhancing Kubernetes Authorization with Multiple Webhooks and Structured Configuration
13+
14+
## Introduction
15+
Kubernetes continuous to evolve to meet the intricate requirements of system
16+
administrators and developers alike. A critical aspect of Kubernetes that
17+
ensures the security and integrity of the cluster is the API server
18+
authorization. Until recently, the configuration of the authorization chain in
19+
kube-apiserver was somewhat rigid, limited to a set of command-line flags and
20+
allowing only a single webhook in the authorization chain. This approach, while
21+
functional, restricted the flexibility needed by cluster administrators to
22+
define complex, fine-grained authorization policies. The latest Structured
23+
Authorization Configuration feature ([KEP-3221](https://kep.k8s.io/3221)) aims
24+
to revolutionize this aspect by introducing a more structured and versatile way
25+
to configure the authorization chain, focusing on enabling multiple webhooks and
26+
providing explicit control mechanisms such as the explicit Deny authorizer.
27+
28+
## The Need for Improvement
29+
Cluster administrators have long sought the ability to specify multiple
30+
authorization webhooks within the API Server handler chain. This need arises
31+
from the desire to create layered security policies, where requests can be
32+
validated against multiple criteria or sets of rules in a specific order. The
33+
previous limitations also made it difficult to declaratively configure the
34+
authorizer chain, leaving no room to efficiently manage complex authorization
35+
scenarios.
36+
37+
The [Structured Authorization Configuration
38+
feature](/docs/reference/access-authn-authz/authorization/#configuring-the-api-server-using-an-authorization-config-file)
39+
addresses these limitations by introducing a configuration file format to
40+
configure Kubernetes API Server Authorization chain. This format allows
41+
specifying multiple webhooks in the authorization chain while all other types of
42+
authorizers should at most be specified once. Each webhook authorizer comes with
43+
its well-defined parameters, including timeout settings, failure policies, and
44+
conditions for invocation with [CEL](/docs/reference/using-api/cel/) rules to
45+
pre-filter requests before they are dispatched to webhooks, helping you to
46+
prevent unnecessary invocations. The configuration also supports automatic
47+
reloading, ensuring changes can be applied dynamically without restarting the
48+
kube-apiserver. This feature not only addresses current limitations, but also
49+
opens up new possibilities for securing and managing Kubernetes clusters more
50+
effectively.
51+
52+
## Sample Configurations
53+
These configuration examples illustrate real world scenarios that need the
54+
ability to specify multiple webhooks with distinct settings, precedence order,
55+
and failure modes.
56+
57+
### Protecting Installed CRDs
58+
Ensuring the availability of Custom Resource Definitions (CRDs) at cluster
59+
startup has been a key demand, One of the blockers for having a controller
60+
reconciling those CRDs is to have a protection mechanism for them, which can be
61+
achieved through multiple Authorization Webhooks. This was not possible before.
62+
Now with the Structured Authorization Configuration feature, administrators can
63+
specify multiple webhooks offering a solution where RBAC falls short, especially
64+
in denying permissions to 'non-system' users for certain CRDs.
65+
66+
Assuming the following for this scenario:
67+
- The "protected" CRDs are installed in the kube-system namespace.
68+
- They can only be modified by users in the group
69+
`system:serviceaccounts:kube-superuser`
70+
71+
```yaml
72+
apiVersion: apiserver.config.k8s.io/v1beta1
73+
kind: AuthorizationConfiguration
74+
authorizers:
75+
- type: Webhook
76+
name: system-crd-protector
77+
webhook:
78+
unauthorizedTTL: 30s
79+
timeout: 3s
80+
subjectAccessReviewVersion: v1
81+
matchConditionSubjectAccessReviewVersion: v1
82+
failurePolicy: Deny
83+
connectionInfo:
84+
type: KubeConfig
85+
kubeConfigFile: /kube-system-authz-webhook.yaml
86+
matchConditions:
87+
# only send resource requests to the webhook
88+
- expression: has(request.resourceAttributes)
89+
# only intercept requests to kube-system
90+
- expression: request.resourceAttributes.namespace == 'kube-system'
91+
# don't intercept requests from kube-system service accounts
92+
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
93+
# only intercept update, delete or deletecollection requests
94+
- expression: request.resourceAttributes.verb in ['update', 'delete','deletecollection']
95+
- type: Node
96+
- type: RBAC
97+
```
98+
99+
### Preventing unnecessarily nested webhooks
100+
A system administrator wants to apply specific validations to requests before
101+
handling them off to webhooks using frameworks like Open Policy Agent. In the
102+
past, this would require running nested webhooks within the one added to the
103+
authorization chain to achieve the desired result. The Structured Authorization
104+
Configuration feature simplifies this process, offering a structured API to
105+
selectively trigger additional webhooks when needed. It also enables
106+
administrators to set distinct failure policies for each webhook, ensuring more
107+
consistent and predictable responses.
108+
109+
```yaml
110+
apiVersion: apiserver.config.k8s.io/v1beta1
111+
kind: AuthorizationConfiguration
112+
authorizers:
113+
- name: system-crd-protector
114+
type: Webhook
115+
webhook:
116+
unauthorizedTTL: 30s
117+
timeout: 3s
118+
subjectAccessReviewVersion: v1
119+
matchConditionSubjectAccessReviewVersion: v1
120+
failurePolicy: Deny
121+
connectionInfo:
122+
type: KubeConfig
123+
kubeConfigFile: /kube-system-authz-webhook.yaml
124+
matchConditions:
125+
# only send resource requests to the webhook
126+
- expression: has(request.resourceAttributes)
127+
# only intercept requests to kube-system
128+
- expression: request.resourceAttributes.namespace == 'kube-system'
129+
# don't intercept requests from kube-system service accounts
130+
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
131+
- type: Node
132+
- type: RBAC
133+
- name: opa
134+
type: Webhook
135+
webhook:
136+
unauthorizedTTL: 30s
137+
timeout: 3s
138+
subjectAccessReviewVersion: v1
139+
matchConditionSubjectAccessReviewVersion: v1
140+
failurePolicy: Deny
141+
connectionInfo:
142+
type: KubeConfig
143+
kubeConfigFile: /opa-default-authz-webhook.yaml
144+
matchConditions:
145+
# only send resource requests to the webhook
146+
- expression: has(request.resourceAttributes)
147+
# only intercept requests to default namespace
148+
- expression: request.resourceAttributes.namespace == 'default'
149+
# don't intercept requests from default service accounts
150+
- expression: !('system:serviceaccounts:default' in request.user.groups)
151+
```
152+
153+
## What's next?
154+
For Kubernetes v1.31, we expect the feature to stay in beta while we get more
155+
feedback. Then once the feature is ready for GA, the feature flag will be
156+
removed.
157+
158+
You can learn more about this feature on the [structured authorization
159+
configuration](/docs/reference/access-authn-authz/authorization/#configuring-the-api-server-using-an-authorization-config-file)
160+
Kubernetes doc website. You can also follow along on the
161+
[KEP-3221](https://kep.k8s.io/3221) to track progress across the coming
162+
Kubernetes releases.
163+
164+
## Call to action
165+
In this post, we have covered the benefits the Structured Authorization
166+
Configuration feature brings in Kubernetes v1.30 and few sample configurations
167+
for real world scenarios. To use this feature, you must specify the path to the
168+
authorization configuration using the `--authorization-config` command line
169+
argument. From Kubernetes 1.30, the feature is in beta and enabled by default.
170+
If you want to keep using command line flags instead of a configuration file,
171+
those will continue to work as-is.
172+
173+
We would love to hear your feedback on this feature. In particular, we would
174+
like feedback from Kubernetes cluster administrators and authorization webhook
175+
implementors as they go through the process of building their integrations with
176+
this new API. Please reach out to us on the
177+
[#sig-auth-authorizers-dev](https://kubernetes.slack.com/archives/C05EZFX1Z2L)
178+
channel on Kubernetes Slack.
179+
180+
## How to get involved
181+
If you are interested in getting involved in the development of this feature,
182+
share feedback, or participate in any other ongoing SIG Auth projects, please
183+
reach out on the [#sig-auth](https://kubernetes.slack.com/archives/C0EN96KUY)
184+
channel on Kubernetes Slack.
185+
186+
You are also welcome to join the bi-weekly [SIG Auth
187+
meetings](https://github.com/kubernetes/community/blob/master/sig-auth/README.md#meetings)
188+
held every-other Wednesday.
189+
190+
## Acknowledgements
191+
This feature has been an effort driven by contributors from several different
192+
companies. We would like to extend a huge thank you to everyone that contributed
193+
their time and effort to help make this possible.

0 commit comments

Comments
 (0)