Skip to content

Commit 4515061

Browse files
committed
add config with comments for fields
Signed-off-by: Rita Zhang <[email protected]>
1 parent e6aa049 commit 4515061

File tree

1 file changed

+108
-8
lines changed

1 file changed

+108
-8
lines changed

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

Lines changed: 108 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,110 @@ opens up new possibilities for securing and managing Kubernetes clusters more
5151
effectively.
5252

5353
## Sample Configurations
54-
These configuration examples illustrate real world scenarios that need the
55-
ability to specify multiple webhooks with distinct settings, precedence order,
56-
and failure modes.
54+
Here is a sample structured authorization configuration along with descriptions
55+
for all fields, their defaults, and possible values.
56+
57+
```yaml
58+
apiVersion: apiserver.config.k8s.io/v1beta1
59+
kind: AuthorizationConfiguration
60+
authorizers:
61+
- type: Webhook
62+
# Name used to describe the authorizer
63+
# This is explicitly used in monitoring machinery for metrics
64+
# Note:
65+
# - Validation for this field is similar to how K8s labels are validated today.
66+
# Required, with no default
67+
name: webhook
68+
webhook:
69+
# The duration to cache 'authorized' responses from the webhook
70+
# authorizer.
71+
# Same as setting `--authorization-webhook-cache-authorized-ttl` flag
72+
# Default: 5m0s
73+
authorizedTTL: 30s
74+
# The duration to cache 'unauthorized' responses from the webhook
75+
# authorizer.
76+
# Same as setting `--authorization-webhook-cache-unauthorized-ttl` flag
77+
# Default: 30s
78+
unauthorizedTTL: 30s
79+
# Timeout for the webhook request
80+
# Maximum allowed is 30s.
81+
# Required, with no default.
82+
timeout: 3s
83+
# The API version of the authorization.k8s.io SubjectAccessReview to
84+
# send to and expect from the webhook.
85+
# Same as setting `--authorization-webhook-version` flag
86+
# Required, with no default
87+
# Valid values: v1beta1, v1
88+
subjectAccessReviewVersion: v1
89+
# MatchConditionSubjectAccessReviewVersion specifies the SubjectAccessReview
90+
# version the CEL expressions are evaluated against
91+
# Valid values: v1
92+
# Required, no default value
93+
matchConditionSubjectAccessReviewVersion: v1
94+
# Controls the authorization decision when a webhook request fails to
95+
# complete or returns a malformed response or errors evaluating
96+
# matchConditions.
97+
# Valid values:
98+
# - NoOpinion: continue to subsequent authorizers to see if one of
99+
# them allows the request
100+
# - Deny: reject the request without consulting subsequent authorizers
101+
# Required, with no default.
102+
failurePolicy: Deny
103+
connectionInfo:
104+
# Controls how the webhook should communicate with the server.
105+
# Valid values:
106+
# - KubeConfig: use the file specified in kubeConfigFile to locate the
107+
# server.
108+
# - InClusterConfig: use the in-cluster configuration to call the
109+
# SubjectAccessReview API hosted by kube-apiserver. This mode is not
110+
# allowed for kube-apiserver.
111+
type: KubeConfig
112+
# Path to KubeConfigFile for connection info
113+
# Required, if connectionInfo.Type is KubeConfig
114+
kubeConfigFile: /kube-system-authz-webhook.yaml
115+
# matchConditions is a list of conditions that must be met for a request to be sent to this
116+
# webhook. An empty list of matchConditions matches all requests.
117+
# There are a maximum of 64 match conditions allowed.
118+
#
119+
# The exact matching logic is (in order):
120+
# 1. If at least one matchCondition evaluates to FALSE, then the webhook is skipped.
121+
# 2. If ALL matchConditions evaluate to TRUE, then the webhook is called.
122+
# 3. If at least one matchCondition evaluates to an error (but none are FALSE):
123+
# - If failurePolicy=Deny, then the webhook rejects the request
124+
# - If failurePolicy=NoOpinion, then the error is ignored and the webhook is skipped
125+
matchConditions:
126+
# expression represents the expression which will be evaluated by CEL. Must evaluate to bool.
127+
# CEL expressions have access to the contents of the SubjectAccessReview in v1 version.
128+
# If version specified by subjectAccessReviewVersion in the request variable is v1beta1,
129+
# the contents would be converted to the v1 version before evaluating the CEL expression.
130+
#
131+
# Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
132+
#
133+
# only send resource requests to the webhook
134+
- expression: has(request.resourceAttributes)
135+
# only intercept requests to kube-system
136+
- expression: request.resourceAttributes.namespace == 'kube-system'
137+
# don't intercept requests from kube-system service accounts
138+
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
139+
- type: Node
140+
name: node
141+
- type: RBAC
142+
name: rbac
143+
- type: Webhook
144+
name: in-cluster-authorizer
145+
webhook:
146+
authorizedTTL: 5m
147+
unauthorizedTTL: 30s
148+
timeout: 3s
149+
subjectAccessReviewVersion: v1
150+
failurePolicy: NoOpinion
151+
connectionInfo:
152+
type: InClusterConfig
153+
```
154+
155+
The following configuration examples illustrate real world scenarios that need
156+
the ability to specify multiple webhooks with distinct settings, precedence
157+
order, and failure modes.
57158
58159
### Protecting Installed CRDs
59160
Ensuring the availability of Custom Resource Definitions (CRDs) at cluster
@@ -171,16 +272,15 @@ argument. From Kubernetes 1.30, the feature is in beta and enabled by default.
171272
If you want to keep using command line flags instead of a configuration file,
172273
those will continue to work as-is.
173274

174-
The following kind Cluster configuration sets that command argument on the
275+
The following kind Cluster configuration sets that command argument on the
175276
APIserver to load an AuthorizationConfiguration from a file
176-
(`authorization_config.yaml`) in the files folder.
177-
Any needed kubeconfig and certificate files can also be put in the files
178-
directory.
277+
(`authorization_config.yaml`) in the files folder. Any needed kubeconfig and
278+
certificate files can also be put in the files directory.
179279
```yaml
180280
kind: Cluster
181281
apiVersion: kind.x-k8s.io/v1alpha4
182282
featureGates:
183-
StructuredAuthorizationConfiguration: true # enabled by default in v1.30
283+
StructuredAuthorizationConfiguration: true # only required for v1.29; enabled by default in v1.30
184284
kubeadmConfigPatches:
185285
- |
186286
kind: ClusterConfiguration

0 commit comments

Comments
 (0)