Skip to content

Commit 7f8a28c

Browse files
committed
fixup! KEP-3221: update kep
Signed-off-by: Nabarun Pal <[email protected]>
1 parent 2f4318e commit 7f8a28c

File tree

1 file changed

+49
-8
lines changed
  • keps/sig-auth/3221-structured-authorization-configuration

1 file changed

+49
-8
lines changed

keps/sig-auth/3221-structured-authorization-configuration/README.md

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ authorizers:
123123
type: KubeConfig
124124
kubeConfigFile: /kube-system-authz-webhook.yaml
125125
matchConditions:
126-
- expression: |
127-
has(request.resourceAttributes) && (request.resourceAttributes.namespace == 'kube-system')
128-
- expression: |
129-
!('system:serviceaccounts:kube-system' in request.user.groups)
126+
# only send resource requests to the webhook
127+
- expression: has(request.resourceAttributes)
128+
# only intercept requests to kube-system
129+
- expression: request.resourceAttributes.namespace == 'kube-system'
130+
# don't intercept requests from kube-system service accounts
131+
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
130132
- type: Node
131133
- type: RBAC
132134
- type: Webhook
@@ -158,6 +160,42 @@ update/delete the protected set of CRDs.
158160

159161
Relevant Discussion Thread is sig-apimachinery: https://groups.google.com/g/kubernetes-sig-api-machinery/c/MBa19WTETMQ
160162

163+
A relevant configuration for this scenario with the assumptions:
164+
1. The "protected" CRDs are installed in the kube-system namespace.
165+
2. They can only be modified by users in the group "system:serviceaccounts:kube-superuser"
166+
167+
Note: The above are hypothetical for now since there has been no decision on
168+
protection rules for system CRDs. The below example is only for demonstration
169+
purposes.
170+
```yaml
171+
apiVersion: apiserver.config.k8s.io/v1alpha1
172+
kind: AuthorizationConfiguration
173+
authorizers:
174+
- type: Webhook
175+
name: system-crd-protector
176+
webhook:
177+
unauthorizedTTL: 30s
178+
timeout: 3s
179+
subjectAccessReviewVersion: v1
180+
failurePolicy: Deny
181+
connectionInfo:
182+
type: KubeConfig
183+
kubeConfigFile: /kube-system-authz-webhook.yaml
184+
matchConditions:
185+
# only send resource requests to the webhook
186+
- expression: has(request.resourceAttributes)
187+
# only intercept requests to kube-system (assumption i)
188+
- expression: request.resourceAttributes.namespace == 'kube-system'
189+
# don't intercept requests from kube-system service accounts
190+
- expression: !('system:serviceaccounts:kube-kube-superuser' in request.user.groups)
191+
# only intercept update, delete and deletecollection requests
192+
- expression: request.resourceAttributes.verb == 'update'
193+
- expression: request.resourceAttributes.verb == 'delete'
194+
- expression: request.resourceAttributes.verb == 'deletecollection'
195+
- type: Node
196+
- type: RBAC
197+
```
198+
161199
#### Story 2: Preventing unnecessarily nested webhooks
162200

163201
Consider a system administrator who would like to apply a set of validations
@@ -298,10 +336,13 @@ authorizers:
298336
# CEL expressions have access to the contents of the SubjectAccessReview
299337
# in the version specified by subjectAccessReviewVersion in the request variable.
300338
# Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
301-
- expression: |
302-
has(request.resourceAttributes) && (request.resourceAttributes.namespace == 'kube-system')
303-
- expression: |
304-
!('system:serviceaccounts:kube-system' in request.user.groups)
339+
#
340+
# only send resource requests to the webhook
341+
- expression: has(request.resourceAttributes)
342+
# only intercept requests to kube-system
343+
- expression: request.resourceAttributes.namespace == 'kube-system'
344+
# don't intercept requests from kube-system service accounts
345+
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
305346
- type: Node
306347
- type: RBAC
307348
- type: Webhook

0 commit comments

Comments
 (0)