1/*
2Copyright The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17
18// This file was autogenerated by go-to-protobuf. Do not edit it manually!
19
20syntax = "proto2";
21
22package k8s.io.api.admissionregistration.v1beta1;
23
24import "k8s.io/api/admissionregistration/v1/generated.proto";
25import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
26import "k8s.io/apimachinery/pkg/runtime/generated.proto";
27import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
28
29// Package-wide variables from generator "generated".
30option go_package = "k8s.io/api/admissionregistration/v1beta1";
31
32// AuditAnnotation describes how to produce an audit annotation for an API request.
33message AuditAnnotation {
34 // key specifies the audit annotation key. The audit annotation keys of
35 // a ValidatingAdmissionPolicy must be unique. The key must be a qualified
36 // name ([A-Za-z0-9][-A-Za-z0-9_.]*) no more than 63 bytes in length.
37 //
38 // The key is combined with the resource name of the
39 // ValidatingAdmissionPolicy to construct an audit annotation key:
40 // "{ValidatingAdmissionPolicy name}/{key}".
41 //
42 // If an admission webhook uses the same resource name as this ValidatingAdmissionPolicy
43 // and the same audit annotation key, the annotation key will be identical.
44 // In this case, the first annotation written with the key will be included
45 // in the audit event and all subsequent annotations with the same key
46 // will be discarded.
47 //
48 // Required.
49 optional string key = 1;
50
51 // valueExpression represents the expression which is evaluated by CEL to
52 // produce an audit annotation value. The expression must evaluate to either
53 // a string or null value. If the expression evaluates to a string, the
54 // audit annotation is included with the string value. If the expression
55 // evaluates to null or empty string the audit annotation will be omitted.
56 // The valueExpression may be no longer than 5kb in length.
57 // If the result of the valueExpression is more than 10kb in length, it
58 // will be truncated to 10kb.
59 //
60 // If multiple ValidatingAdmissionPolicyBinding resources match an
61 // API request, then the valueExpression will be evaluated for
62 // each binding. All unique values produced by the valueExpressions
63 // will be joined together in a comma-separated list.
64 //
65 // Required.
66 optional string valueExpression = 2;
67}
68
69// ExpressionWarning is a warning information that targets a specific expression.
70message ExpressionWarning {
71 // The path to the field that refers the expression.
72 // For example, the reference to the expression of the first item of
73 // validations is "spec.validations[0].expression"
74 optional string fieldRef = 2;
75
76 // The content of type checking information in a human-readable form.
77 // Each line of the warning contains the type that the expression is checked
78 // against, followed by the type check error from the compiler.
79 optional string warning = 3;
80}
81
82// MatchCondition represents a condition which must be fulfilled for a request to be sent to a webhook.
83message MatchCondition {
84 // Name is an identifier for this match condition, used for strategic merging of MatchConditions,
85 // as well as providing an identifier for logging purposes. A good name should be descriptive of
86 // the associated expression.
87 // Name must be a qualified name consisting of alphanumeric characters, '-', '_' or '.', and
88 // must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or
89 // '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]') with an
90 // optional DNS subdomain prefix and '/' (e.g. 'example.com/MyName')
91 //
92 // Required.
93 optional string name = 1;
94
95 // Expression represents the expression which will be evaluated by CEL. Must evaluate to bool.
96 // CEL expressions have access to the contents of the AdmissionRequest and Authorizer, organized into CEL variables:
97 //
98 // 'object' - The object from the incoming request. The value is null for DELETE requests.
99 // 'oldObject' - The existing object. The value is null for CREATE requests.
100 // 'request' - Attributes of the admission request(/pkg/apis/admission/types.go#AdmissionRequest).
101 // 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.
102 // See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
103 // 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the
104 // request resource.
105 // Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
106 //
107 // Required.
108 optional string expression = 2;
109}
110
111// MatchResources decides whether to run the admission control policy on an object based
112// on whether it meets the match criteria.
113// The exclude rules take precedence over include rules (if a resource matches both, it is excluded)
114// +structType=atomic
115message MatchResources {
116 // NamespaceSelector decides whether to run the admission control policy on an object based
117 // on whether the namespace for that object matches the selector. If the
118 // object itself is a namespace, the matching is performed on
119 // object.metadata.labels. If the object is another cluster scoped resource,
120 // it never skips the policy.
121 //
122 // For example, to run the webhook on any objects whose namespace is not
123 // associated with "runlevel" of "0" or "1"; you will set the selector as
124 // follows:
125 // "namespaceSelector": {
126 // "matchExpressions": [
127 // {
128 // "key": "runlevel",
129 // "operator": "NotIn",
130 // "values": [
131 // "0",
132 // "1"
133 // ]
134 // }
135 // ]
136 // }
137 //
138 // If instead you want to only run the policy on any objects whose
139 // namespace is associated with the "environment" of "prod" or "staging";
140 // you will set the selector as follows:
141 // "namespaceSelector": {
142 // "matchExpressions": [
143 // {
144 // "key": "environment",
145 // "operator": "In",
146 // "values": [
147 // "prod",
148 // "staging"
149 // ]
150 // }
151 // ]
152 // }
153 //
154 // See
155 // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
156 // for more examples of label selectors.
157 //
158 // Default to the empty LabelSelector, which matches everything.
159 // +optional
160 optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector namespaceSelector = 1;
161
162 // ObjectSelector decides whether to run the validation based on if the
163 // object has matching labels. objectSelector is evaluated against both
164 // the oldObject and newObject that would be sent to the cel validation, and
165 // is considered to match if either object matches the selector. A null
166 // object (oldObject in the case of create, or newObject in the case of
167 // delete) or an object that cannot have labels (like a
168 // DeploymentRollback or a PodProxyOptions object) is not considered to
169 // match.
170 // Use the object selector only if the webhook is opt-in, because end
171 // users may skip the admission webhook by setting the labels.
172 // Default to the empty LabelSelector, which matches everything.
173 // +optional
174 optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector objectSelector = 2;
175
176 // ResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches.
177 // The policy cares about an operation if it matches _any_ Rule.
178 // +listType=atomic
179 // +optional
180 repeated NamedRuleWithOperations resourceRules = 3;
181
182 // ExcludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about.
183 // The exclude rules take precedence over include rules (if a resource matches both, it is excluded)
184 // +listType=atomic
185 // +optional
186 repeated NamedRuleWithOperations excludeResourceRules = 4;
187
188 // matchPolicy defines how the "MatchResources" list is used to match incoming requests.
189 // Allowed values are "Exact" or "Equivalent".
190 //
191 // - Exact: match a request only if it exactly matches a specified rule.
192 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
193 // but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
194 // a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the ValidatingAdmissionPolicy.
195 //
196 // - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
197 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
198 // and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
199 // a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the ValidatingAdmissionPolicy.
200 //
201 // Defaults to "Equivalent"
202 // +optional
203 optional string matchPolicy = 7;
204}
205
206// MutatingWebhook describes an admission webhook and the resources and operations it applies to.
207message MutatingWebhook {
208 // The name of the admission webhook.
209 // Name should be fully qualified, e.g., imagepolicy.kubernetes.io, where
210 // "imagepolicy" is the name of the webhook, and kubernetes.io is the name
211 // of the organization.
212 // Required.
213 optional string name = 1;
214
215 // ClientConfig defines how to communicate with the hook.
216 // Required
217 optional WebhookClientConfig clientConfig = 2;
218
219 // Rules describes what operations on what resources/subresources the webhook cares about.
220 // The webhook cares about an operation if it matches _any_ Rule.
221 // However, in order to prevent ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks
222 // from putting the cluster in a state which cannot be recovered from without completely
223 // disabling the plugin, ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks are never called
224 // on admission requests for ValidatingWebhookConfiguration and MutatingWebhookConfiguration objects.
225 // +listType=atomic
226 repeated k8s.io.api.admissionregistration.v1.RuleWithOperations rules = 3;
227
228 // FailurePolicy defines how unrecognized errors from the admission endpoint are handled -
229 // allowed values are Ignore or Fail. Defaults to Ignore.
230 // +optional
231 optional string failurePolicy = 4;
232
233 // matchPolicy defines how the "rules" list is used to match incoming requests.
234 // Allowed values are "Exact" or "Equivalent".
235 //
236 // - Exact: match a request only if it exactly matches a specified rule.
237 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
238 // but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
239 // a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
240 //
241 // - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
242 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
243 // and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
244 // a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
245 //
246 // Defaults to "Exact"
247 // +optional
248 optional string matchPolicy = 9;
249
250 // NamespaceSelector decides whether to run the webhook on an object based
251 // on whether the namespace for that object matches the selector. If the
252 // object itself is a namespace, the matching is performed on
253 // object.metadata.labels. If the object is another cluster scoped resource,
254 // it never skips the webhook.
255 //
256 // For example, to run the webhook on any objects whose namespace is not
257 // associated with "runlevel" of "0" or "1"; you will set the selector as
258 // follows:
259 // "namespaceSelector": {
260 // "matchExpressions": [
261 // {
262 // "key": "runlevel",
263 // "operator": "NotIn",
264 // "values": [
265 // "0",
266 // "1"
267 // ]
268 // }
269 // ]
270 // }
271 //
272 // If instead you want to only run the webhook on any objects whose
273 // namespace is associated with the "environment" of "prod" or "staging";
274 // you will set the selector as follows:
275 // "namespaceSelector": {
276 // "matchExpressions": [
277 // {
278 // "key": "environment",
279 // "operator": "In",
280 // "values": [
281 // "prod",
282 // "staging"
283 // ]
284 // }
285 // ]
286 // }
287 //
288 // See
289 // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
290 // for more examples of label selectors.
291 //
292 // Default to the empty LabelSelector, which matches everything.
293 // +optional
294 optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector namespaceSelector = 5;
295
296 // ObjectSelector decides whether to run the webhook based on if the
297 // object has matching labels. objectSelector is evaluated against both
298 // the oldObject and newObject that would be sent to the webhook, and
299 // is considered to match if either object matches the selector. A null
300 // object (oldObject in the case of create, or newObject in the case of
301 // delete) or an object that cannot have labels (like a
302 // DeploymentRollback or a PodProxyOptions object) is not considered to
303 // match.
304 // Use the object selector only if the webhook is opt-in, because end
305 // users may skip the admission webhook by setting the labels.
306 // Default to the empty LabelSelector, which matches everything.
307 // +optional
308 optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector objectSelector = 11;
309
310 // SideEffects states whether this webhook has side effects.
311 // Acceptable values are: Unknown, None, Some, NoneOnDryRun
312 // Webhooks with side effects MUST implement a reconciliation system, since a request may be
313 // rejected by a future step in the admission chain and the side effects therefore need to be undone.
314 // Requests with the dryRun attribute will be auto-rejected if they match a webhook with
315 // sideEffects == Unknown or Some. Defaults to Unknown.
316 // +optional
317 optional string sideEffects = 6;
318
319 // TimeoutSeconds specifies the timeout for this webhook. After the timeout passes,
320 // the webhook call will be ignored or the API call will fail based on the
321 // failure policy.
322 // The timeout value must be between 1 and 30 seconds.
323 // Default to 30 seconds.
324 // +optional
325 optional int32 timeoutSeconds = 7;
326
327 // AdmissionReviewVersions is an ordered list of preferred `AdmissionReview`
328 // versions the Webhook expects. API server will try to use first version in
329 // the list which it supports. If none of the versions specified in this list
330 // supported by API server, validation will fail for this object.
331 // If a persisted webhook configuration specifies allowed versions and does not
332 // include any versions known to the API Server, calls to the webhook will fail
333 // and be subject to the failure policy.
334 // Default to `['v1beta1']`.
335 // +optional
336 // +listType=atomic
337 repeated string admissionReviewVersions = 8;
338
339 // reinvocationPolicy indicates whether this webhook should be called multiple times as part of a single admission evaluation.
340 // Allowed values are "Never" and "IfNeeded".
341 //
342 // Never: the webhook will not be called more than once in a single admission evaluation.
343 //
344 // IfNeeded: the webhook will be called at least one additional time as part of the admission evaluation
345 // if the object being admitted is modified by other admission plugins after the initial webhook call.
346 // Webhooks that specify this option *must* be idempotent, able to process objects they previously admitted.
347 // Note:
348 // * the number of additional invocations is not guaranteed to be exactly one.
349 // * if additional invocations result in further modifications to the object, webhooks are not guaranteed to be invoked again.
350 // * webhooks that use this option may be reordered to minimize the number of additional invocations.
351 // * to validate an object after all mutations are guaranteed complete, use a validating admission webhook instead.
352 //
353 // Defaults to "Never".
354 // +optional
355 optional string reinvocationPolicy = 10;
356
357 // MatchConditions is a list of conditions that must be met for a request to be sent to this
358 // webhook. Match conditions filter requests that have already been matched by the rules,
359 // namespaceSelector, and objectSelector. An empty list of matchConditions matches all requests.
360 // There are a maximum of 64 match conditions allowed.
361 //
362 // The exact matching logic is (in order):
363 // 1. If ANY matchCondition evaluates to FALSE, the webhook is skipped.
364 // 2. If ALL matchConditions evaluate to TRUE, the webhook is called.
365 // 3. If any matchCondition evaluates to an error (but none are FALSE):
366 // - If failurePolicy=Fail, reject the request
367 // - If failurePolicy=Ignore, the error is ignored and the webhook is skipped
368 //
369 // +patchMergeKey=name
370 // +patchStrategy=merge
371 // +listType=map
372 // +listMapKey=name
373 // +optional
374 repeated MatchCondition matchConditions = 12;
375}
376
377// MutatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and may change the object.
378// Deprecated in v1.16, planned for removal in v1.19. Use admissionregistration.k8s.io/v1 MutatingWebhookConfiguration instead.
379message MutatingWebhookConfiguration {
380 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
381 // +optional
382 optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
383
384 // Webhooks is a list of webhooks and the affected resources and operations.
385 // +optional
386 // +patchMergeKey=name
387 // +patchStrategy=merge
388 // +listType=map
389 // +listMapKey=name
390 repeated MutatingWebhook Webhooks = 2;
391}
392
393// MutatingWebhookConfigurationList is a list of MutatingWebhookConfiguration.
394message MutatingWebhookConfigurationList {
395 // Standard list metadata.
396 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
397 // +optional
398 optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
399
400 // List of MutatingWebhookConfiguration.
401 repeated MutatingWebhookConfiguration items = 2;
402}
403
404// NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.
405// +structType=atomic
406message NamedRuleWithOperations {
407 // ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.
408 // +listType=atomic
409 // +optional
410 repeated string resourceNames = 1;
411
412 // RuleWithOperations is a tuple of Operations and Resources.
413 optional k8s.io.api.admissionregistration.v1.RuleWithOperations ruleWithOperations = 2;
414}
415
416// ParamKind is a tuple of Group Kind and Version.
417// +structType=atomic
418message ParamKind {
419 // APIVersion is the API group version the resources belong to.
420 // In format of "group/version".
421 // Required.
422 optional string apiVersion = 1;
423
424 // Kind is the API kind the resources belong to.
425 // Required.
426 optional string kind = 2;
427}
428
429// ParamRef describes how to locate the params to be used as input to
430// expressions of rules applied by a policy binding.
431// +structType=atomic
432message ParamRef {
433 // name is the name of the resource being referenced.
434 //
435 // One of `name` or `selector` must be set, but `name` and `selector` are
436 // mutually exclusive properties. If one is set, the other must be unset.
437 //
438 // A single parameter used for all admission requests can be configured
439 // by setting the `name` field, leaving `selector` blank, and setting namespace
440 // if `paramKind` is namespace-scoped.
441 optional string name = 1;
442
443 // namespace is the namespace of the referenced resource. Allows limiting
444 // the search for params to a specific namespace. Applies to both `name` and
445 // `selector` fields.
446 //
447 // A per-namespace parameter may be used by specifying a namespace-scoped
448 // `paramKind` in the policy and leaving this field empty.
449 //
450 // - If `paramKind` is cluster-scoped, this field MUST be unset. Setting this
451 // field results in a configuration error.
452 //
453 // - If `paramKind` is namespace-scoped, the namespace of the object being
454 // evaluated for admission will be used when this field is left unset. Take
455 // care that if this is left empty the binding must not match any cluster-scoped
456 // resources, which will result in an error.
457 //
458 // +optional
459 optional string namespace = 2;
460
461 // selector can be used to match multiple param objects based on their labels.
462 // Supply selector: {} to match all resources of the ParamKind.
463 //
464 // If multiple params are found, they are all evaluated with the policy expressions
465 // and the results are ANDed together.
466 //
467 // One of `name` or `selector` must be set, but `name` and `selector` are
468 // mutually exclusive properties. If one is set, the other must be unset.
469 //
470 // +optional
471 optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 3;
472
473 // `parameterNotFoundAction` controls the behavior of the binding when the resource
474 // exists, and name or selector is valid, but there are no parameters
475 // matched by the binding. If the value is set to `Allow`, then no
476 // matched parameters will be treated as successful validation by the binding.
477 // If set to `Deny`, then no matched parameters will be subject to the
478 // `failurePolicy` of the policy.
479 //
480 // Allowed values are `Allow` or `Deny`
481 //
482 // Required
483 optional string parameterNotFoundAction = 4;
484}
485
486// ServiceReference holds a reference to Service.legacy.k8s.io
487message ServiceReference {
488 // `namespace` is the namespace of the service.
489 // Required
490 optional string namespace = 1;
491
492 // `name` is the name of the service.
493 // Required
494 optional string name = 2;
495
496 // `path` is an optional URL path which will be sent in any request to
497 // this service.
498 // +optional
499 optional string path = 3;
500
501 // If specified, the port on the service that hosting webhook.
502 // Default to 443 for backward compatibility.
503 // `port` should be a valid port number (1-65535, inclusive).
504 // +optional
505 optional int32 port = 4;
506}
507
508// TypeChecking contains results of type checking the expressions in the
509// ValidatingAdmissionPolicy
510message TypeChecking {
511 // The type checking warnings for each expression.
512 // +optional
513 // +listType=atomic
514 repeated ExpressionWarning expressionWarnings = 1;
515}
516
517// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
518// +genclient
519// +genclient:nonNamespaced
520// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
521// +k8s:prerelease-lifecycle-gen:introduced=1.28
522// ValidatingAdmissionPolicy describes the definition of an admission validation policy that accepts or rejects an object without changing it.
523message ValidatingAdmissionPolicy {
524 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
525 // +optional
526 optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
527
528 // Specification of the desired behavior of the ValidatingAdmissionPolicy.
529 optional ValidatingAdmissionPolicySpec spec = 2;
530
531 // The status of the ValidatingAdmissionPolicy, including warnings that are useful to determine if the policy
532 // behaves in the expected way.
533 // Populated by the system.
534 // Read-only.
535 // +optional
536 optional ValidatingAdmissionPolicyStatus status = 3;
537}
538
539// ValidatingAdmissionPolicyBinding binds the ValidatingAdmissionPolicy with paramerized resources.
540// ValidatingAdmissionPolicyBinding and parameter CRDs together define how cluster administrators configure policies for clusters.
541//
542// For a given admission request, each binding will cause its policy to be
543// evaluated N times, where N is 1 for policies/bindings that don't use
544// params, otherwise N is the number of parameters selected by the binding.
545//
546// The CEL expressions of a policy must have a computed CEL cost below the maximum
547// CEL budget. Each evaluation of the policy is given an independent CEL cost budget.
548// Adding/removing policies, bindings, or params can not affect whether a
549// given (policy, binding, param) combination is within its own CEL budget.
550message ValidatingAdmissionPolicyBinding {
551 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
552 // +optional
553 optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
554
555 // Specification of the desired behavior of the ValidatingAdmissionPolicyBinding.
556 optional ValidatingAdmissionPolicyBindingSpec spec = 2;
557}
558
559// ValidatingAdmissionPolicyBindingList is a list of ValidatingAdmissionPolicyBinding.
560message ValidatingAdmissionPolicyBindingList {
561 // Standard list metadata.
562 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
563 // +optional
564 optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
565
566 // List of PolicyBinding.
567 repeated ValidatingAdmissionPolicyBinding items = 2;
568}
569
570// ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding.
571message ValidatingAdmissionPolicyBindingSpec {
572 // PolicyName references a ValidatingAdmissionPolicy name which the ValidatingAdmissionPolicyBinding binds to.
573 // If the referenced resource does not exist, this binding is considered invalid and will be ignored
574 // Required.
575 optional string policyName = 1;
576
577 // paramRef specifies the parameter resource used to configure the admission control policy.
578 // It should point to a resource of the type specified in ParamKind of the bound ValidatingAdmissionPolicy.
579 // If the policy specifies a ParamKind and the resource referred to by ParamRef does not exist, this binding is considered mis-configured and the FailurePolicy of the ValidatingAdmissionPolicy applied.
580 // If the policy does not specify a ParamKind then this field is ignored, and the rules are evaluated without a param.
581 // +optional
582 optional ParamRef paramRef = 2;
583
584 // MatchResources declares what resources match this binding and will be validated by it.
585 // Note that this is intersected with the policy's matchConstraints, so only requests that are matched by the policy can be selected by this.
586 // If this is unset, all resources matched by the policy are validated by this binding
587 // When resourceRules is unset, it does not constrain resource matching. If a resource is matched by the other fields of this object, it will be validated.
588 // Note that this is differs from ValidatingAdmissionPolicy matchConstraints, where resourceRules are required.
589 // +optional
590 optional MatchResources matchResources = 3;
591
592 // validationActions declares how Validations of the referenced ValidatingAdmissionPolicy are enforced.
593 // If a validation evaluates to false it is always enforced according to these actions.
594 //
595 // Failures defined by the ValidatingAdmissionPolicy's FailurePolicy are enforced according
596 // to these actions only if the FailurePolicy is set to Fail, otherwise the failures are
597 // ignored. This includes compilation errors, runtime errors and misconfigurations of the policy.
598 //
599 // validationActions is declared as a set of action values. Order does
600 // not matter. validationActions may not contain duplicates of the same action.
601 //
602 // The supported actions values are:
603 //
604 // "Deny" specifies that a validation failure results in a denied request.
605 //
606 // "Warn" specifies that a validation failure is reported to the request client
607 // in HTTP Warning headers, with a warning code of 299. Warnings can be sent
608 // both for allowed or denied admission responses.
609 //
610 // "Audit" specifies that a validation failure is included in the published
611 // audit event for the request. The audit event will contain a
612 // `validation.policy.admission.k8s.io/validation_failure` audit annotation
613 // with a value containing the details of the validation failures, formatted as
614 // a JSON list of objects, each with the following fields:
615 // - message: The validation failure message string
616 // - policy: The resource name of the ValidatingAdmissionPolicy
617 // - binding: The resource name of the ValidatingAdmissionPolicyBinding
618 // - expressionIndex: The index of the failed validations in the ValidatingAdmissionPolicy
619 // - validationActions: The enforcement actions enacted for the validation failure
620 // Example audit annotation:
621 // `"validation.policy.admission.k8s.io/validation_failure": "[{\"message\": \"Invalid value\", {\"policy\": \"policy.example.com\", {\"binding\": \"policybinding.example.com\", {\"expressionIndex\": \"1\", {\"validationActions\": [\"Audit\"]}]"`
622 //
623 // Clients should expect to handle additional values by ignoring
624 // any values not recognized.
625 //
626 // "Deny" and "Warn" may not be used together since this combination
627 // needlessly duplicates the validation failure both in the
628 // API response body and the HTTP warning headers.
629 //
630 // Required.
631 // +listType=set
632 repeated string validationActions = 4;
633}
634
635// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
636// +k8s:prerelease-lifecycle-gen:introduced=1.28
637// ValidatingAdmissionPolicyList is a list of ValidatingAdmissionPolicy.
638message ValidatingAdmissionPolicyList {
639 // Standard list metadata.
640 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
641 // +optional
642 optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
643
644 // List of ValidatingAdmissionPolicy.
645 repeated ValidatingAdmissionPolicy items = 2;
646}
647
648// ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy.
649message ValidatingAdmissionPolicySpec {
650 // ParamKind specifies the kind of resources used to parameterize this policy.
651 // If absent, there are no parameters for this policy and the param CEL variable will not be provided to validation expressions.
652 // If ParamKind refers to a non-existent kind, this policy definition is mis-configured and the FailurePolicy is applied.
653 // If paramKind is specified but paramRef is unset in ValidatingAdmissionPolicyBinding, the params variable will be null.
654 // +optional
655 optional ParamKind paramKind = 1;
656
657 // MatchConstraints specifies what resources this policy is designed to validate.
658 // The AdmissionPolicy cares about a request if it matches _all_ Constraints.
659 // However, in order to prevent clusters from being put into an unstable state that cannot be recovered from via the API
660 // ValidatingAdmissionPolicy cannot match ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding.
661 // Required.
662 optional MatchResources matchConstraints = 2;
663
664 // Validations contain CEL expressions which is used to apply the validation.
665 // Validations and AuditAnnotations may not both be empty; a minimum of one Validations or AuditAnnotations is
666 // required.
667 // +listType=atomic
668 // +optional
669 repeated Validation validations = 3;
670
671 // failurePolicy defines how to handle failures for the admission policy. Failures can
672 // occur from CEL expression parse errors, type check errors, runtime errors and invalid
673 // or mis-configured policy definitions or bindings.
674 //
675 // A policy is invalid if spec.paramKind refers to a non-existent Kind.
676 // A binding is invalid if spec.paramRef.name refers to a non-existent resource.
677 //
678 // failurePolicy does not define how validations that evaluate to false are handled.
679 //
680 // When failurePolicy is set to Fail, ValidatingAdmissionPolicyBinding validationActions
681 // define how failures are enforced.
682 //
683 // Allowed values are Ignore or Fail. Defaults to Fail.
684 // +optional
685 optional string failurePolicy = 4;
686
687 // auditAnnotations contains CEL expressions which are used to produce audit
688 // annotations for the audit event of the API request.
689 // validations and auditAnnotations may not both be empty; a least one of validations or auditAnnotations is
690 // required.
691 // +listType=atomic
692 // +optional
693 repeated AuditAnnotation auditAnnotations = 5;
694
695 // MatchConditions is a list of conditions that must be met for a request to be validated.
696 // Match conditions filter requests that have already been matched by the rules,
697 // namespaceSelector, and objectSelector. An empty list of matchConditions matches all requests.
698 // There are a maximum of 64 match conditions allowed.
699 //
700 // If a parameter object is provided, it can be accessed via the `params` handle in the same
701 // manner as validation expressions.
702 //
703 // The exact matching logic is (in order):
704 // 1. If ANY matchCondition evaluates to FALSE, the policy is skipped.
705 // 2. If ALL matchConditions evaluate to TRUE, the policy is evaluated.
706 // 3. If any matchCondition evaluates to an error (but none are FALSE):
707 // - If failurePolicy=Fail, reject the request
708 // - If failurePolicy=Ignore, the policy is skipped
709 //
710 // +patchMergeKey=name
711 // +patchStrategy=merge
712 // +listType=map
713 // +listMapKey=name
714 // +optional
715 repeated MatchCondition matchConditions = 6;
716
717 // Variables contain definitions of variables that can be used in composition of other expressions.
718 // Each variable is defined as a named CEL expression.
719 // The variables defined here will be available under `variables` in other expressions of the policy
720 // except MatchConditions because MatchConditions are evaluated before the rest of the policy.
721 //
722 // The expression of a variable can refer to other variables defined earlier in the list but not those after.
723 // Thus, Variables must be sorted by the order of first appearance and acyclic.
724 // +patchMergeKey=name
725 // +patchStrategy=merge
726 // +listType=map
727 // +listMapKey=name
728 // +optional
729 repeated Variable variables = 7;
730}
731
732// ValidatingAdmissionPolicyStatus represents the status of an admission validation policy.
733message ValidatingAdmissionPolicyStatus {
734 // The generation observed by the controller.
735 // +optional
736 optional int64 observedGeneration = 1;
737
738 // The results of type checking for each expression.
739 // Presence of this field indicates the completion of the type checking.
740 // +optional
741 optional TypeChecking typeChecking = 2;
742
743 // The conditions represent the latest available observations of a policy's current state.
744 // +optional
745 // +listType=map
746 // +listMapKey=type
747 repeated k8s.io.apimachinery.pkg.apis.meta.v1.Condition conditions = 3;
748}
749
750// ValidatingWebhook describes an admission webhook and the resources and operations it applies to.
751message ValidatingWebhook {
752 // The name of the admission webhook.
753 // Name should be fully qualified, e.g., imagepolicy.kubernetes.io, where
754 // "imagepolicy" is the name of the webhook, and kubernetes.io is the name
755 // of the organization.
756 // Required.
757 optional string name = 1;
758
759 // ClientConfig defines how to communicate with the hook.
760 // Required
761 optional WebhookClientConfig clientConfig = 2;
762
763 // Rules describes what operations on what resources/subresources the webhook cares about.
764 // The webhook cares about an operation if it matches _any_ Rule.
765 // However, in order to prevent ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks
766 // from putting the cluster in a state which cannot be recovered from without completely
767 // disabling the plugin, ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks are never called
768 // on admission requests for ValidatingWebhookConfiguration and MutatingWebhookConfiguration objects.
769 // +listType=atomic
770 repeated k8s.io.api.admissionregistration.v1.RuleWithOperations rules = 3;
771
772 // FailurePolicy defines how unrecognized errors from the admission endpoint are handled -
773 // allowed values are Ignore or Fail. Defaults to Ignore.
774 // +optional
775 optional string failurePolicy = 4;
776
777 // matchPolicy defines how the "rules" list is used to match incoming requests.
778 // Allowed values are "Exact" or "Equivalent".
779 //
780 // - Exact: match a request only if it exactly matches a specified rule.
781 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
782 // but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
783 // a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
784 //
785 // - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
786 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
787 // and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
788 // a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
789 //
790 // Defaults to "Exact"
791 // +optional
792 optional string matchPolicy = 9;
793
794 // NamespaceSelector decides whether to run the webhook on an object based
795 // on whether the namespace for that object matches the selector. If the
796 // object itself is a namespace, the matching is performed on
797 // object.metadata.labels. If the object is another cluster scoped resource,
798 // it never skips the webhook.
799 //
800 // For example, to run the webhook on any objects whose namespace is not
801 // associated with "runlevel" of "0" or "1"; you will set the selector as
802 // follows:
803 // "namespaceSelector": {
804 // "matchExpressions": [
805 // {
806 // "key": "runlevel",
807 // "operator": "NotIn",
808 // "values": [
809 // "0",
810 // "1"
811 // ]
812 // }
813 // ]
814 // }
815 //
816 // If instead you want to only run the webhook on any objects whose
817 // namespace is associated with the "environment" of "prod" or "staging";
818 // you will set the selector as follows:
819 // "namespaceSelector": {
820 // "matchExpressions": [
821 // {
822 // "key": "environment",
823 // "operator": "In",
824 // "values": [
825 // "prod",
826 // "staging"
827 // ]
828 // }
829 // ]
830 // }
831 //
832 // See
833 // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
834 // for more examples of label selectors.
835 //
836 // Default to the empty LabelSelector, which matches everything.
837 // +optional
838 optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector namespaceSelector = 5;
839
840 // ObjectSelector decides whether to run the webhook based on if the
841 // object has matching labels. objectSelector is evaluated against both
842 // the oldObject and newObject that would be sent to the webhook, and
843 // is considered to match if either object matches the selector. A null
844 // object (oldObject in the case of create, or newObject in the case of
845 // delete) or an object that cannot have labels (like a
846 // DeploymentRollback or a PodProxyOptions object) is not considered to
847 // match.
848 // Use the object selector only if the webhook is opt-in, because end
849 // users may skip the admission webhook by setting the labels.
850 // Default to the empty LabelSelector, which matches everything.
851 // +optional
852 optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector objectSelector = 10;
853
854 // SideEffects states whether this webhook has side effects.
855 // Acceptable values are: Unknown, None, Some, NoneOnDryRun
856 // Webhooks with side effects MUST implement a reconciliation system, since a request may be
857 // rejected by a future step in the admission chain and the side effects therefore need to be undone.
858 // Requests with the dryRun attribute will be auto-rejected if they match a webhook with
859 // sideEffects == Unknown or Some. Defaults to Unknown.
860 // +optional
861 // +listType=atomic
862 optional string sideEffects = 6;
863
864 // TimeoutSeconds specifies the timeout for this webhook. After the timeout passes,
865 // the webhook call will be ignored or the API call will fail based on the
866 // failure policy.
867 // The timeout value must be between 1 and 30 seconds.
868 // Default to 30 seconds.
869 // +optional
870 optional int32 timeoutSeconds = 7;
871
872 // AdmissionReviewVersions is an ordered list of preferred `AdmissionReview`
873 // versions the Webhook expects. API server will try to use first version in
874 // the list which it supports. If none of the versions specified in this list
875 // supported by API server, validation will fail for this object.
876 // If a persisted webhook configuration specifies allowed versions and does not
877 // include any versions known to the API Server, calls to the webhook will fail
878 // and be subject to the failure policy.
879 // Default to `['v1beta1']`.
880 // +optional
881 // +listType=atomic
882 repeated string admissionReviewVersions = 8;
883
884 // MatchConditions is a list of conditions that must be met for a request to be sent to this
885 // webhook. Match conditions filter requests that have already been matched by the rules,
886 // namespaceSelector, and objectSelector. An empty list of matchConditions matches all requests.
887 // There are a maximum of 64 match conditions allowed.
888 //
889 // The exact matching logic is (in order):
890 // 1. If ANY matchCondition evaluates to FALSE, the webhook is skipped.
891 // 2. If ALL matchConditions evaluate to TRUE, the webhook is called.
892 // 3. If any matchCondition evaluates to an error (but none are FALSE):
893 // - If failurePolicy=Fail, reject the request
894 // - If failurePolicy=Ignore, the error is ignored and the webhook is skipped
895 //
896 // +patchMergeKey=name
897 // +patchStrategy=merge
898 // +listType=map
899 // +listMapKey=name
900 // +optional
901 repeated MatchCondition matchConditions = 11;
902}
903
904// ValidatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and object without changing it.
905// Deprecated in v1.16, planned for removal in v1.19. Use admissionregistration.k8s.io/v1 ValidatingWebhookConfiguration instead.
906message ValidatingWebhookConfiguration {
907 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
908 // +optional
909 optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
910
911 // Webhooks is a list of webhooks and the affected resources and operations.
912 // +optional
913 // +patchMergeKey=name
914 // +patchStrategy=merge
915 // +listType=map
916 // +listMapKey=name
917 repeated ValidatingWebhook Webhooks = 2;
918}
919
920// ValidatingWebhookConfigurationList is a list of ValidatingWebhookConfiguration.
921message ValidatingWebhookConfigurationList {
922 // Standard list metadata.
923 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
924 // +optional
925 optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
926
927 // List of ValidatingWebhookConfiguration.
928 repeated ValidatingWebhookConfiguration items = 2;
929}
930
931// Validation specifies the CEL expression which is used to apply the validation.
932message Validation {
933 // Expression represents the expression which will be evaluated by CEL.
934 // ref: https://github.com/google/cel-spec
935 // CEL expressions have access to the contents of the API request/response, organized into CEL variables as well as some other useful variables:
936 //
937 // - 'object' - The object from the incoming request. The value is null for DELETE requests.
938 // - 'oldObject' - The existing object. The value is null for CREATE requests.
939 // - 'request' - Attributes of the API request([ref](/pkg/apis/admission/types.go#AdmissionRequest)).
940 // - 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind.
941 // - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources.
942 // - 'variables' - Map of composited variables, from its name to its lazily evaluated value.
943 // For example, a variable named 'foo' can be accessed as 'variables.foo'.
944 // - 'authorizer' - A CEL Authorizer. May be used to perform authorization checks for the principal (user or service account) of the request.
945 // See https://pkg.go.dev/k8s.io/apiserver/pkg/cel/library#Authz
946 // - 'authorizer.requestResource' - A CEL ResourceCheck constructed from the 'authorizer' and configured with the
947 // request resource.
948 //
949 // The `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the
950 // object. No other metadata properties are accessible.
951 //
952 // Only property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible.
953 // Accessible property names are escaped according to the following rules when accessed in the expression:
954 // - '__' escapes to '__underscores__'
955 // - '.' escapes to '__dot__'
956 // - '-' escapes to '__dash__'
957 // - '/' escapes to '__slash__'
958 // - Property names that exactly match a CEL RESERVED keyword escape to '__{keyword}__'. The keywords are:
959 // "true", "false", "null", "in", "as", "break", "const", "continue", "else", "for", "function", "if",
960 // "import", "let", "loop", "package", "namespace", "return".
961 // Examples:
962 // - Expression accessing a property named "namespace": {"Expression": "object.__namespace__ > 0"}
963 // - Expression accessing a property named "x-prop": {"Expression": "object.x__dash__prop > 0"}
964 // - Expression accessing a property named "redact__d": {"Expression": "object.redact__underscores__d > 0"}
965 //
966 // Equality on arrays with list type of 'set' or 'map' ignores element order, i.e. [1, 2] == [2, 1].
967 // Concatenation on arrays with x-kubernetes-list-type use the semantics of the list type:
968 // - 'set': `X + Y` performs a union where the array positions of all elements in `X` are preserved and
969 // non-intersecting elements in `Y` are appended, retaining their partial order.
970 // - 'map': `X + Y` performs a merge where the array positions of all keys in `X` are preserved but the values
971 // are overwritten by values in `Y` when the key sets of `X` and `Y` intersect. Elements in `Y` with
972 // non-intersecting keys are appended, retaining their partial order.
973 // Required.
974 optional string Expression = 1;
975
976 // Message represents the message displayed when validation fails. The message is required if the Expression contains
977 // line breaks. The message must not contain line breaks.
978 // If unset, the message is "failed rule: {Rule}".
979 // e.g. "must be a URL with the host matching spec.host"
980 // If the Expression contains line breaks. Message is required.
981 // The message must not contain line breaks.
982 // If unset, the message is "failed Expression: {Expression}".
983 // +optional
984 optional string message = 2;
985
986 // Reason represents a machine-readable description of why this validation failed.
987 // If this is the first validation in the list to fail, this reason, as well as the
988 // corresponding HTTP response code, are used in the
989 // HTTP response to the client.
990 // The currently supported reasons are: "Unauthorized", "Forbidden", "Invalid", "RequestEntityTooLarge".
991 // If not set, StatusReasonInvalid is used in the response to the client.
992 // +optional
993 optional string reason = 3;
994
995 // messageExpression declares a CEL expression that evaluates to the validation failure message that is returned when this rule fails.
996 // Since messageExpression is used as a failure message, it must evaluate to a string.
997 // If both message and messageExpression are present on a validation, then messageExpression will be used if validation fails.
998 // If messageExpression results in a runtime error, the runtime error is logged, and the validation failure message is produced
999 // as if the messageExpression field were unset. If messageExpression evaluates to an empty string, a string with only spaces, or a string
1000 // that contains line breaks, then the validation failure message will also be produced as if the messageExpression field were unset, and
1001 // the fact that messageExpression produced an empty string/string with only spaces/string with line breaks will be logged.
1002 // messageExpression has access to all the same variables as the `expression` except for 'authorizer' and 'authorizer.requestResource'.
1003 // Example:
1004 // "object.x must be less than max ("+string(params.max)+")"
1005 // +optional
1006 optional string messageExpression = 4;
1007}
1008
1009// Variable is the definition of a variable that is used for composition. A variable is defined as a named expression.
1010// +structType=atomic
1011message Variable {
1012 // Name is the name of the variable. The name must be a valid CEL identifier and unique among all variables.
1013 // The variable can be accessed in other expressions through `variables`
1014 // For example, if name is "foo", the variable will be available as `variables.foo`
1015 optional string Name = 1;
1016
1017 // Expression is the expression that will be evaluated as the value of the variable.
1018 // The CEL expression has access to the same identifiers as the CEL expressions in Validation.
1019 optional string Expression = 2;
1020}
1021
1022// WebhookClientConfig contains the information to make a TLS
1023// connection with the webhook
1024message WebhookClientConfig {
1025 // `url` gives the location of the webhook, in standard URL form
1026 // (`scheme://host:port/path`). Exactly one of `url` or `service`
1027 // must be specified.
1028 //
1029 // The `host` should not refer to a service running in the cluster; use
1030 // the `service` field instead. The host might be resolved via external
1031 // DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
1032 // in-cluster DNS as that would be a layering violation). `host` may
1033 // also be an IP address.
1034 //
1035 // Please note that using `localhost` or `127.0.0.1` as a `host` is
1036 // risky unless you take great care to run this webhook on all hosts
1037 // which run an apiserver which might need to make calls to this
1038 // webhook. Such installs are likely to be non-portable, i.e., not easy
1039 // to turn up in a new cluster.
1040 //
1041 // The scheme must be "https"; the URL must begin with "https://".
1042 //
1043 // A path is optional, and if present may be any string permissible in
1044 // a URL. You may use the path to pass an arbitrary string to the
1045 // webhook, for example, a cluster identifier.
1046 //
1047 // Attempting to use a user or basic auth e.g. "user:password@" is not
1048 // allowed. Fragments ("#...") and query parameters ("?...") are not
1049 // allowed, either.
1050 //
1051 // +optional
1052 optional string url = 3;
1053
1054 // `service` is a reference to the service for this webhook. Either
1055 // `service` or `url` must be specified.
1056 //
1057 // If the webhook is running within the cluster, then you should use `service`.
1058 //
1059 // +optional
1060 optional ServiceReference service = 1;
1061
1062 // `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.
1063 // If unspecified, system trust roots on the apiserver are used.
1064 // +optional
1065 optional bytes caBundle = 2;
1066}
1067
View as plain text