Debian Codegraph @

pkg/apis/apiserver/v1beta1/types.go

raw
1 /*
2 Copyright 2017 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package v1beta1
18
19 import (
20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21 tracingapi "k8s.io/component-base/tracing/api/v1"
22 )
23
24 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
25
26 // EgressSelectorConfiguration provides versioned configuration for egress selector clients.
27 type EgressSelectorConfiguration struct {
28 metav1.TypeMeta `json:",inline"`
29
30 // connectionServices contains a list of egress selection client configurations
31 EgressSelections []EgressSelection `json:"egressSelections"`
32 }
33
34 // EgressSelection provides the configuration for a single egress selection client.
35 type EgressSelection struct {
36 // name is the name of the egress selection.
37 // Currently supported values are "controlplane", "master", "etcd" and "cluster"
38 // The "master" egress selector is deprecated in favor of "controlplane"
39 Name string `json:"name"`
40
41 // connection is the exact information used to configure the egress selection
42 Connection Connection `json:"connection"`
43 }
44
45 // Connection provides the configuration for a single egress selection client.
46 type Connection struct {
47 // Protocol is the protocol used to connect from client to the konnectivity server.
48 ProxyProtocol ProtocolType `json:"proxyProtocol,omitempty"`
49
50 // Transport defines the transport configurations we use to dial to the konnectivity server.
51 // This is required if ProxyProtocol is HTTPConnect or GRPC.
52 // +optional
53 Transport *Transport `json:"transport,omitempty"`
54 }
55
56 // ProtocolType is a set of valid values for Connection.ProtocolType
57 type ProtocolType string
58
59 // Valid types for ProtocolType for konnectivity server
60 const (
61 // Use HTTPConnect to connect to konnectivity server
62 ProtocolHTTPConnect ProtocolType = "HTTPConnect"
63 // Use grpc to connect to konnectivity server
64 ProtocolGRPC ProtocolType = "GRPC"
65 // Connect directly (skip konnectivity server)
66 ProtocolDirect ProtocolType = "Direct"
67 )
68
69 // Transport defines the transport configurations we use to dial to the konnectivity server
70 type Transport struct {
71 // TCP is the TCP configuration for communicating with the konnectivity server via TCP
72 // ProxyProtocol of GRPC is not supported with TCP transport at the moment
73 // Requires at least one of TCP or UDS to be set
74 // +optional
75 TCP *TCPTransport `json:"tcp,omitempty"`
76
77 // UDS is the UDS configuration for communicating with the konnectivity server via UDS
78 // Requires at least one of TCP or UDS to be set
79 // +optional
80 UDS *UDSTransport `json:"uds,omitempty"`
81 }
82
83 // TCPTransport provides the information to connect to konnectivity server via TCP
84 type TCPTransport struct {
85 // URL is the location of the konnectivity server to connect to.
86 // As an example it might be "https://127.0.0.1:8131"
87 URL string `json:"url,omitempty"`
88
89 // TLSConfig is the config needed to use TLS when connecting to konnectivity server
90 // +optional
91 TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
92 }
93
94 // UDSTransport provides the information to connect to konnectivity server via UDS
95 type UDSTransport struct {
96 // UDSName is the name of the unix domain socket to connect to konnectivity server
97 // This does not use a unix:// prefix. (Eg: /etc/srv/kubernetes/konnectivity-server/konnectivity-server.socket)
98 UDSName string `json:"udsName,omitempty"`
99 }
100
101 // TLSConfig provides the authentication information to connect to konnectivity server
102 // Only used with TCPTransport
103 type TLSConfig struct {
104 // caBundle is the file location of the CA to be used to determine trust with the konnectivity server.
105 // Must be absent/empty if TCPTransport.URL is prefixed with http://
106 // If absent while TCPTransport.URL is prefixed with https://, default to system trust roots.
107 // +optional
108 CABundle string `json:"caBundle,omitempty"`
109
110 // clientKey is the file location of the client key to be used in mtls handshakes with the konnectivity server.
111 // Must be absent/empty if TCPTransport.URL is prefixed with http://
112 // Must be configured if TCPTransport.URL is prefixed with https://
113 // +optional
114 ClientKey string `json:"clientKey,omitempty"`
115
116 // clientCert is the file location of the client certificate to be used in mtls handshakes with the konnectivity server.
117 // Must be absent/empty if TCPTransport.URL is prefixed with http://
118 // Must be configured if TCPTransport.URL is prefixed with https://
119 // +optional
120 ClientCert string `json:"clientCert,omitempty"`
121 }
122
123 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
124
125 // TracingConfiguration provides versioned configuration for tracing clients.
126 type TracingConfiguration struct {
127 metav1.TypeMeta `json:",inline"`
128
129 // Embed the component config tracing configuration struct
130 tracingapi.TracingConfiguration `json:",inline"`
131 }
132
133 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
134
135 // AuthenticationConfiguration provides versioned configuration for authentication.
136 type AuthenticationConfiguration struct {
137 metav1.TypeMeta
138
139 // jwt is a list of authenticator to authenticate Kubernetes users using
140 // JWT compliant tokens. The authenticator will attempt to parse a raw ID token,
141 // verify it's been signed by the configured issuer. The public key to verify the
142 // signature is discovered from the issuer's public endpoint using OIDC discovery.
143 // For an incoming token, each JWT authenticator will be attempted in
144 // the order in which it is specified in this list. Note however that
145 // other authenticators may run before or after the JWT authenticators.
146 // The specific position of JWT authenticators in relation to other
147 // authenticators is neither defined nor stable across releases. Since
148 // each JWT authenticator must have a unique issuer URL, at most one
149 // JWT authenticator will attempt to cryptographically validate the token.
150 //
151 // The minimum valid JWT payload must contain the following claims:
152 // {
153 // "iss": "https://issuer.example.com",
154 // "aud": ["audience"],
155 // "exp": 1234567890,
156 // "<username claim>": "username"
157 // }
158 JWT []JWTAuthenticator `json:"jwt"`
159
160 // If present --anonymous-auth must not be set
161 Anonymous *AnonymousAuthConfig `json:"anonymous,omitempty"`
162 }
163
164 // AnonymousAuthConfig provides the configuration for the anonymous authenticator.
165 type AnonymousAuthConfig struct {
166 Enabled bool `json:"enabled"`
167
168 // If set, anonymous auth is only allowed if the request meets one of the
169 // conditions.
170 Conditions []AnonymousAuthCondition `json:"conditions,omitempty"`
171 }
172
173 // AnonymousAuthCondition describes the condition under which anonymous auth
174 // should be enabled.
175 type AnonymousAuthCondition struct {
176 // Path for which anonymous auth is enabled.
177 Path string `json:"path"`
178 }
179
180 // JWTAuthenticator provides the configuration for a single JWT authenticator.
181 type JWTAuthenticator struct {
182 // issuer contains the basic OIDC provider connection options.
183 // +required
184 Issuer Issuer `json:"issuer"`
185
186 // claimValidationRules are rules that are applied to validate token claims to authenticate users.
187 // +optional
188 ClaimValidationRules []ClaimValidationRule `json:"claimValidationRules,omitempty"`
189
190 // claimMappings points claims of a token to be treated as user attributes.
191 // +required
192 ClaimMappings ClaimMappings `json:"claimMappings"`
193
194 // userValidationRules are rules that are applied to final user before completing authentication.
195 // These allow invariants to be applied to incoming identities such as preventing the
196 // use of the system: prefix that is commonly used by Kubernetes components.
197 // The validation rules are logically ANDed together and must all return true for the validation to pass.
198 // +optional
199 UserValidationRules []UserValidationRule `json:"userValidationRules,omitempty"`
200 }
201
202 // Issuer provides the configuration for an external provider's specific settings.
203 type Issuer struct {
204 // url points to the issuer URL in a format https://url or https://url/path.
205 // This must match the "iss" claim in the presented JWT, and the issuer returned from discovery.
206 // Same value as the --oidc-issuer-url flag.
207 // Discovery information is fetched from "{url}/.well-known/openid-configuration" unless overridden by discoveryURL.
208 // Required to be unique across all JWT authenticators.
209 // Note that egress selection configuration is not used for this network connection.
210 // +required
211 URL string `json:"url"`
212
213 // discoveryURL, if specified, overrides the URL used to fetch discovery
214 // information instead of using "{url}/.well-known/openid-configuration".
215 // The exact value specified is used, so "/.well-known/openid-configuration"
216 // must be included in discoveryURL if needed.
217 //
218 // The "issuer" field in the fetched discovery information must match the "issuer.url" field
219 // in the AuthenticationConfiguration and will be used to validate the "iss" claim in the presented JWT.
220 // This is for scenarios where the well-known and jwks endpoints are hosted at a different
221 // location than the issuer (such as locally in the cluster).
222 //
223 // Example:
224 // A discovery url that is exposed using kubernetes service 'oidc' in namespace 'oidc-namespace'
225 // and discovery information is available at '/.well-known/openid-configuration'.
226 // discoveryURL: "https://oidc.oidc-namespace/.well-known/openid-configuration"
227 // certificateAuthority is used to verify the TLS connection and the hostname on the leaf certificate
228 // must be set to 'oidc.oidc-namespace'.
229 //
230 // curl https://oidc.oidc-namespace/.well-known/openid-configuration (.discoveryURL field)
231 // {
232 // issuer: "https://oidc.example.com" (.url field)
233 // }
234 //
235 // discoveryURL must be different from url.
236 // Required to be unique across all JWT authenticators.
237 // Note that egress selection configuration is not used for this network connection.
238 // +optional
239 DiscoveryURL *string `json:"discoveryURL,omitempty"`
240
241 // certificateAuthority contains PEM-encoded certificate authority certificates
242 // used to validate the connection when fetching discovery information.
243 // If unset, the system verifier is used.
244 // Same value as the content of the file referenced by the --oidc-ca-file flag.
245 // +optional
246 CertificateAuthority string `json:"certificateAuthority,omitempty"`
247
248 // audiences is the set of acceptable audiences the JWT must be issued to.
249 // At least one of the entries must match the "aud" claim in presented JWTs.
250 // Same value as the --oidc-client-id flag (though this field supports an array).
251 // Required to be non-empty.
252 // +required
253 Audiences []string `json:"audiences"`
254
255 // audienceMatchPolicy defines how the "audiences" field is used to match the "aud" claim in the presented JWT.
256 // Allowed values are:
257 // 1. "MatchAny" when multiple audiences are specified and
258 // 2. empty (or unset) or "MatchAny" when a single audience is specified.
259 //
260 // - MatchAny: the "aud" claim in the presented JWT must match at least one of the entries in the "audiences" field.
261 // For example, if "audiences" is ["foo", "bar"], the "aud" claim in the presented JWT must contain either "foo" or "bar" (and may contain both).
262 //
263 // - "": The match policy can be empty (or unset) when a single audience is specified in the "audiences" field. The "aud" claim in the presented JWT must contain the single audience (and may contain others).
264 //
265 // For more nuanced audience validation, use claimValidationRules.
266 // example: claimValidationRule[].expression: 'sets.equivalent(claims.aud, ["bar", "foo", "baz"])' to require an exact match.
267 // +optional
268 AudienceMatchPolicy AudienceMatchPolicyType `json:"audienceMatchPolicy,omitempty"`
269 }
270
271 // AudienceMatchPolicyType is a set of valid values for issuer.audienceMatchPolicy
272 type AudienceMatchPolicyType string
273
274 // Valid types for AudienceMatchPolicyType
275 const (
276 // MatchAny means the "aud" claim in the presented JWT must match at least one of the entries in the "audiences" field.
277 AudienceMatchPolicyMatchAny AudienceMatchPolicyType = "MatchAny"
278 )
279
280 // ClaimValidationRule provides the configuration for a single claim validation rule.
281 type ClaimValidationRule struct {
282 // claim is the name of a required claim.
283 // Same as --oidc-required-claim flag.
284 // Only string claim keys are supported.
285 // Mutually exclusive with expression and message.
286 // +optional
287 Claim string `json:"claim,omitempty"`
288 // requiredValue is the value of a required claim.
289 // Same as --oidc-required-claim flag.
290 // Only string claim values are supported.
291 // If claim is set and requiredValue is not set, the claim must be present with a value set to the empty string.
292 // Mutually exclusive with expression and message.
293 // +optional
294 RequiredValue string `json:"requiredValue,omitempty"`
295
296 // expression represents the expression which will be evaluated by CEL.
297 // Must produce a boolean.
298 //
299 // CEL expressions have access to the contents of the token claims, organized into CEL variable:
300 // - 'claims' is a map of claim names to claim values.
301 // For example, a variable named 'sub' can be accessed as 'claims.sub'.
302 // Nested claims can be accessed using dot notation, e.g. 'claims.foo.bar'.
303 // Must return true for the validation to pass.
304 //
305 // Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
306 //
307 // Mutually exclusive with claim and requiredValue.
308 // +optional
309 Expression string `json:"expression,omitempty"`
310 // message customizes the returned error message when expression returns false.
311 // message is a literal string.
312 // Mutually exclusive with claim and requiredValue.
313 // +optional
314 Message string `json:"message,omitempty"`
315 }
316
317 // ClaimMappings provides the configuration for claim mapping
318 type ClaimMappings struct {
319 // username represents an option for the username attribute.
320 // The claim's value must be a singular string.
321 // Same as the --oidc-username-claim and --oidc-username-prefix flags.
322 // If username.expression is set, the expression must produce a string value.
323 // If username.expression uses 'claims.email', then 'claims.email_verified' must be used in
324 // username.expression or extra[*].valueExpression or claimValidationRules[*].expression.
325 // An example claim validation rule expression that matches the validation automatically
326 // applied when username.claim is set to 'email' is 'claims.?email_verified.orValue(true) == true'. By explicitly comparing
327 // the value to true, we let type-checking see the result will be a boolean, and to make sure a non-boolean email_verified
328 // claim will be caught at runtime.
329 //
330 // In the flag based approach, the --oidc-username-claim and --oidc-username-prefix are optional. If --oidc-username-claim is not set,
331 // the default value is "sub". For the authentication config, there is no defaulting for claim or prefix. The claim and prefix must be set explicitly.
332 // For claim, if --oidc-username-claim was not set with legacy flag approach, configure username.claim="sub" in the authentication config.
333 // For prefix:
334 // (1) --oidc-username-prefix="-", no prefix was added to the username. For the same behavior using authentication config,
335 // set username.prefix=""
336 // (2) --oidc-username-prefix="" and --oidc-username-claim != "email", prefix was "<value of --oidc-issuer-url>#". For the same
337 // behavior using authentication config, set username.prefix="<value of issuer.url>#"
338 // (3) --oidc-username-prefix="<value>". For the same behavior using authentication config, set username.prefix="<value>"
339 // +required
340 Username PrefixedClaimOrExpression `json:"username"`
341 // groups represents an option for the groups attribute.
342 // The claim's value must be a string or string array claim.
343 // If groups.claim is set, the prefix must be specified (and can be the empty string).
344 // If groups.expression is set, the expression must produce a string or string array value.
345 // "", [], and null values are treated as the group mapping not being present.
346 // +optional
347 Groups PrefixedClaimOrExpression `json:"groups,omitempty"`
348
349 // uid represents an option for the uid attribute.
350 // Claim must be a singular string claim.
351 // If uid.expression is set, the expression must produce a string value.
352 // +optional
353 UID ClaimOrExpression `json:"uid"`
354
355 // extra represents an option for the extra attribute.
356 // expression must produce a string or string array value.
357 // If the value is empty, the extra mapping will not be present.
358 //
359 // hard-coded extra key/value
360 // - key: "foo"
361 // valueExpression: "'bar'"
362 // This will result in an extra attribute - foo: ["bar"]
363 //
364 // hard-coded key, value copying claim value
365 // - key: "foo"
366 // valueExpression: "claims.some_claim"
367 // This will result in an extra attribute - foo: [value of some_claim]
368 //
369 // hard-coded key, value derived from claim value
370 // - key: "admin"
371 // valueExpression: '(has(claims.is_admin) && claims.is_admin) ? "true":""'
372 // This will result in:
373 // - if is_admin claim is present and true, extra attribute - admin: ["true"]
374 // - if is_admin claim is present and false or is_admin claim is not present, no extra attribute will be added
375 //
376 // +optional
377 Extra []ExtraMapping `json:"extra,omitempty"`
378 }
379
380 // PrefixedClaimOrExpression provides the configuration for a single prefixed claim or expression.
381 type PrefixedClaimOrExpression struct {
382 // claim is the JWT claim to use.
383 // Mutually exclusive with expression.
384 // +optional
385 Claim string `json:"claim,omitempty"`
386 // prefix is prepended to claim's value to prevent clashes with existing names.
387 // prefix needs to be set if claim is set and can be the empty string.
388 // Mutually exclusive with expression.
389 // +optional
390 Prefix *string `json:"prefix,omitempty"`
391
392 // expression represents the expression which will be evaluated by CEL.
393 //
394 // CEL expressions have access to the contents of the token claims, organized into CEL variable:
395 // - 'claims' is a map of claim names to claim values.
396 // For example, a variable named 'sub' can be accessed as 'claims.sub'.
397 // Nested claims can be accessed using dot notation, e.g. 'claims.foo.bar'.
398 //
399 // Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
400 //
401 // Mutually exclusive with claim and prefix.
402 // +optional
403 Expression string `json:"expression,omitempty"`
404 }
405
406 // ClaimOrExpression provides the configuration for a single claim or expression.
407 type ClaimOrExpression struct {
408 // claim is the JWT claim to use.
409 // Either claim or expression must be set.
410 // Mutually exclusive with expression.
411 // +optional
412 Claim string `json:"claim,omitempty"`
413
414 // expression represents the expression which will be evaluated by CEL.
415 //
416 // CEL expressions have access to the contents of the token claims, organized into CEL variable:
417 // - 'claims' is a map of claim names to claim values.
418 // For example, a variable named 'sub' can be accessed as 'claims.sub'.
419 // Nested claims can be accessed using dot notation, e.g. 'claims.foo.bar'.
420 //
421 // Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
422 //
423 // Mutually exclusive with claim.
424 // +optional
425 Expression string `json:"expression,omitempty"`
426 }
427
428 // ExtraMapping provides the configuration for a single extra mapping.
429 type ExtraMapping struct {
430 // key is a string to use as the extra attribute key.
431 // key must be a domain-prefix path (e.g. example.org/foo). All characters before the first "/" must be a valid
432 // subdomain as defined by RFC 1123. All characters trailing the first "/" must
433 // be valid HTTP Path characters as defined by RFC 3986.
434 // key must be lowercase.
435 // Required to be unique.
436 // +required
437 Key string `json:"key"`
438
439 // valueExpression is a CEL expression to extract extra attribute value.
440 // valueExpression must produce a string or string array value.
441 // "", [], and null values are treated as the extra mapping not being present.
442 // Empty string values contained within a string array are filtered out.
443 //
444 // CEL expressions have access to the contents of the token claims, organized into CEL variable:
445 // - 'claims' is a map of claim names to claim values.
446 // For example, a variable named 'sub' can be accessed as 'claims.sub'.
447 // Nested claims can be accessed using dot notation, e.g. 'claims.foo.bar'.
448 //
449 // Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
450 //
451 // +required
452 ValueExpression string `json:"valueExpression"`
453 }
454
455 // UserValidationRule provides the configuration for a single user info validation rule.
456 type UserValidationRule struct {
457 // expression represents the expression which will be evaluated by CEL.
458 // Must return true for the validation to pass.
459 //
460 // CEL expressions have access to the contents of UserInfo, organized into CEL variable:
461 // - 'user' - authentication.k8s.io/v1, Kind=UserInfo object
462 // Refer to https://github.com/kubernetes/api/blob/release-1.28/authentication/v1/types.go#L105-L122 for the definition.
463 // API documentation: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#userinfo-v1-authentication-k8s-io
464 //
465 // Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
466 //
467 // +required
468 Expression string `json:"expression"`
469
470 // message customizes the returned error message when rule returns false.
471 // message is a literal string.
472 // +optional
473 Message string `json:"message,omitempty"`
474 }
475
476 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
477
478 type AuthorizationConfiguration struct {
479 metav1.TypeMeta
480
481 // Authorizers is an ordered list of authorizers to
482 // authorize requests against.
483 // This is similar to the --authorization-modes kube-apiserver flag
484 // Must be at least one.
485 Authorizers []AuthorizerConfiguration `json:"authorizers"`
486 }
487
488 const (
489 TypeWebhook AuthorizerType = "Webhook"
490 FailurePolicyNoOpinion string = "NoOpinion"
491 FailurePolicyDeny string = "Deny"
492 AuthorizationWebhookConnectionInfoTypeKubeConfigFile string = "KubeConfigFile"
493 AuthorizationWebhookConnectionInfoTypeInCluster string = "InClusterConfig"
494 )
495
496 type AuthorizerType string
497
498 type AuthorizerConfiguration struct {
499 // Type refers to the type of the authorizer
500 // "Webhook" is supported in the generic API server
501 // Other API servers may support additional authorizer
502 // types like Node, RBAC, ABAC, etc.
503 Type string `json:"type"`
504
505 // Name used to describe the webhook
506 // This is explicitly used in monitoring machinery for metrics
507 // Note: Names must be DNS1123 labels like `myauthorizername` or
508 // subdomains like `myauthorizer.example.domain`
509 // Required, with no default
510 Name string `json:"name"`
511
512 // Webhook defines the configuration for a Webhook authorizer
513 // Must be defined when Type=Webhook
514 // Must not be defined when Type!=Webhook
515 Webhook *WebhookConfiguration `json:"webhook,omitempty"`
516 }
517
518 type WebhookConfiguration struct {
519 // The duration to cache 'authorized' responses from the webhook
520 // authorizer.
521 // Same as setting `--authorization-webhook-cache-authorized-ttl` flag
522 // Default: 5m0s
523 AuthorizedTTL metav1.Duration `json:"authorizedTTL"`
524 // The duration to cache 'unauthorized' responses from the webhook
525 // authorizer.
526 // Same as setting `--authorization-webhook-cache-unauthorized-ttl` flag
527 // Default: 30s
528 UnauthorizedTTL metav1.Duration `json:"unauthorizedTTL"`
529 // Timeout for the webhook request
530 // Maximum allowed value is 30s.
531 // Required, no default value.
532 Timeout metav1.Duration `json:"timeout"`
533 // The API version of the authorization.k8s.io SubjectAccessReview to
534 // send to and expect from the webhook.
535 // Same as setting `--authorization-webhook-version` flag
536 // Valid values: v1beta1, v1
537 // Required, no default value
538 SubjectAccessReviewVersion string `json:"subjectAccessReviewVersion"`
539 // MatchConditionSubjectAccessReviewVersion specifies the SubjectAccessReview
540 // version the CEL expressions are evaluated against
541 // Valid values: v1
542 // Required, no default value
543 MatchConditionSubjectAccessReviewVersion string `json:"matchConditionSubjectAccessReviewVersion"`
544 // Controls the authorization decision when a webhook request fails to
545 // complete or returns a malformed response or errors evaluating
546 // matchConditions.
547 // Valid values:
548 // - NoOpinion: continue to subsequent authorizers to see if one of
549 // them allows the request
550 // - Deny: reject the request without consulting subsequent authorizers
551 // Required, with no default.
552 FailurePolicy string `json:"failurePolicy"`
553
554 // ConnectionInfo defines how we talk to the webhook
555 ConnectionInfo WebhookConnectionInfo `json:"connectionInfo"`
556
557 // matchConditions is a list of conditions that must be met for a request to be sent to this
558 // webhook. An empty list of matchConditions matches all requests.
559 // There are a maximum of 64 match conditions allowed.
560 //
561 // The exact matching logic is (in order):
562 // 1. If at least one matchCondition evaluates to FALSE, then the webhook is skipped.
563 // 2. If ALL matchConditions evaluate to TRUE, then the webhook is called.
564 // 3. If at least one matchCondition evaluates to an error (but none are FALSE):
565 // - If failurePolicy=Deny, then the webhook rejects the request
566 // - If failurePolicy=NoOpinion, then the error is ignored and the webhook is skipped
567 MatchConditions []WebhookMatchCondition `json:"matchConditions"`
568 }
569
570 type WebhookConnectionInfo struct {
571 // Controls how the webhook should communicate with the server.
572 // Valid values:
573 // - KubeConfigFile: use the file specified in kubeConfigFile to locate the
574 // server.
575 // - InClusterConfig: use the in-cluster configuration to call the
576 // SubjectAccessReview API hosted by kube-apiserver. This mode is not
577 // allowed for kube-apiserver.
578 Type string `json:"type"`
579
580 // Path to KubeConfigFile for connection info
581 // Required, if connectionInfo.Type is KubeConfig
582 KubeConfigFile *string `json:"kubeConfigFile"`
583 }
584
585 type WebhookMatchCondition struct {
586 // expression represents the expression which will be evaluated by CEL. Must evaluate to bool.
587 // CEL expressions have access to the contents of the SubjectAccessReview in v1 version.
588 // If version specified by subjectAccessReviewVersion in the request variable is v1beta1,
589 // the contents would be converted to the v1 version before evaluating the CEL expression.
590 //
591 // - 'resourceAttributes' describes information for a resource access request and is unset for non-resource requests. e.g. has(request.resourceAttributes) && request.resourceAttributes.namespace == 'default'
592 // - 'nonResourceAttributes' describes information for a non-resource access request and is unset for resource requests. e.g. has(request.nonResourceAttributes) && request.nonResourceAttributes.path == '/healthz'.
593 // - 'user' is the user to test for. e.g. request.user == 'alice'
594 // - 'groups' is the groups to test for. e.g. ('group1' in request.groups)
595 // - 'extra' corresponds to the user.Info.GetExtra() method from the authenticator.
596 // - 'uid' is the information about the requesting user. e.g. request.uid == '1'
597 //
598 // Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
599 Expression string `json:"expression"`
600 }