@@ -153,7 +153,7 @@ be achieved through Authorization Webhooks. However since `kube-apiserver`
153
153
only allows specifying a single webhook, this would result in cluster
154
154
administrators being not able to specify their own. Support for multiple
155
155
webhooks would make this possible. Moreover, RBAC rules can't be used here
156
- since RBAC allows to one add permissions but not deny them. We won't be able
156
+ since RBAC allows one to add permissions but not deny them. We won't be able
157
157
to add restrictions on 'non-system' users only for a set of resources using
158
158
RBAC; 'non-system' users here refers to anyone who shouldn't be able to
159
159
update/delete the protected set of CRDs.
@@ -202,12 +202,53 @@ Consider a system administrator who would like to apply a set of validations
202
202
to certain requests before handing it off to webhooks defined using frameworks
203
203
like Open Policy Agent.
204
204
205
- They would have to nested webhooks within the one added to the auth chain to
205
+ They would have to run nested webhooks within the one added to the auth chain to
206
206
have the intended effect. This enhancement allows the administrator to configure
207
207
this behaviour via a structured API and invoke the additional webhook only when
208
208
relevant. This also allows administrators to define `failurePolicy` behaviours for
209
209
separate webhooks, leading to more predictable outcomes.
210
210
211
+ The below example is only for demonstration purposes.
212
+ ` ` ` yaml
213
+ apiVersion: apiserver.config.k8s.io/v1alpha1
214
+ kind: AuthorizationConfiguration
215
+ authorizers:
216
+ - type: Webhook
217
+ webhook:
218
+ unauthorizedTTL: 30s
219
+ timeout: 3s
220
+ subjectAccessReviewVersion: v1
221
+ failurePolicy: Deny
222
+ connectionInfo:
223
+ type: KubeConfig
224
+ kubeConfigFile: /kube-system-authz-webhook.yaml
225
+ matchConditions:
226
+ # only send resource requests to the webhook
227
+ - expression: has(request.resourceAttributes)
228
+ # only intercept requests to kube-system
229
+ - expression: request.resourceAttributes.namespace == 'kube-system'
230
+ # don't intercept requests from kube-system service accounts
231
+ - expression: !('system:serviceaccounts:kube-system' in request.user.groups)
232
+ - type: Node
233
+ - type: RBAC
234
+ - type: Webhook
235
+ webhook:
236
+ unauthorizedTTL: 30s
237
+ timeout: 3s
238
+ subjectAccessReviewVersion: v1
239
+ failurePolicy: Deny
240
+ connectionInfo:
241
+ type: KubeConfig
242
+ kubeConfigFile: /opa-kube-system-authz-webhook.yaml
243
+ matchConditions:
244
+ # only send resource requests to the webhook
245
+ - expression: has(request.resourceAttributes)
246
+ # only intercept requests to kube-system
247
+ - expression: request.resourceAttributes.namespace == 'kube-system'
248
+ # don't intercept requests from kube-system service accounts
249
+ - expression: !('system:serviceaccounts:kube-system' in request.user.groups)
250
+ ` ` `
251
+
211
252
# ### Story 3: Denying requests on certain scenarios
212
253
213
254
The authorizer chain should be powerful enough to deny anyone making a request
@@ -249,7 +290,8 @@ will not be able to start. This can be mitigated by fixing the malformed values.
249
290
We would like to introduce a structured file format which allows authorization
250
291
to be configured using a flag (`--authorization-config-file`) which accepts a
251
292
path to a file on the disk. Setting both `--authorization-config-file` and
252
- configuring an authorization webhook will not be allowed. If the user does that,
293
+ configuring an authorization webhook using the `--authorization-webhook-*`
294
+ command line flags will not be allowed. If the user does that,
253
295
there will be an error and API Server would exit right away.
254
296
255
297
The configuration would be validated at startup and the API server will fail to
@@ -259,7 +301,8 @@ The API server will periodically reload the configuration. If it changes, the
259
301
new configuration will be used for the Authorizer chain. If the new configuration
260
302
is invalid, the last known valid configuration will be used. Logging and metrics
261
303
would be used to signal success/failure of a config reload so that cluster admins
262
- can have observability over this process.
304
+ can have observability over this process. Reload must not add or remove Node or RBAC
305
+ authorizers. They can be reordered, but cannot be added or removed.
263
306
264
307
The proposed structure is illustrated below :
265
308
@@ -321,7 +364,7 @@ authorizers:
321
364
# Path to KubeConfigFile for connection info
322
365
# Required, if connectionInfo.Type is KubeConfig
323
366
kubeConfigFile : /kube-system-authz-webhook.yaml
324
- # matchConditions is a list of conditions that must be met for a request to be sent to this
367
+ # matchConditions is a list of conditions that must be met for a request to be sent to this
325
368
# webhook. An empty list of matchConditions matches all requests.
326
369
# There are a maximum of 64 match conditions allowed.
327
370
#
@@ -377,9 +420,8 @@ to the authz webhook for which the expression has been defined. The user would h
377
420
to a `request` variable containing a `SubjectAccessReview` object in the version specified
378
421
by `subjectAccessReviewVersion`.
379
422
380
- The code path for enabling the above will only be triggered if the feature flag will
381
- be enabled until the time the feature flag is removed and configuring authorizer
382
- through a file becomes GA.
423
+ The code path for enabling the above will only be triggered if the feature flag is enabled until
424
+ the feature flag is removed and this feature graduates to GA.
383
425
384
426
# ## Monitoring
385
427
@@ -458,14 +500,14 @@ We should benchmark the cost of some common CEL expressions inside
458
500
# #### Integration tests
459
501
460
502
Integration tests would be added to ensure the following :
461
- - Authorization of requests work in the existing flag based mode (feature flag
462
- turned off)
503
+ - Authorization of requests work in the existing command line flag
504
+ based mode (feature flag turned off)
463
505
- Authorization of requests work with an apiserver bootstrapped with
464
506
authorization configuration file (feature flag turned on)
465
- - without an webhook
466
- - with an webhook - successful request
467
- - with an webhook - error on request with `failurePolicy : Deny`
468
- - with an webhook - error on request with `failurePolicy : NoOpinion`
507
+ - without a webhook
508
+ - with a webhook - successful request
509
+ - with a webhook - error on request with `failurePolicy : Deny`
510
+ - with a webhook - error on request with `failurePolicy : NoOpinion`
469
511
470
512
There will be a mix and match of various authorization mechanisms to ensure all
471
513
desired functionality works.
@@ -592,7 +634,7 @@ Or, they can look at the metrics exposed by `kube-apiserver`.
592
634
# ##### What are the reasonable SLOs (Service Level Objectives) for the enhancement?
593
635
594
636
The amount of errors denoted by `apiserver_authorization_step_webhook_error_total`
595
- is within reasonable limits. A rising value indicate issues with either the
637
+ is within reasonable limits. A rising value indicates issues with either the
596
638
authorizer chain or the webhook itself.
597
639
598
640
# ##### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service?
0 commit comments