blob: 74b878287472dac9c24060d903a96e7e58aab929 [file] [log] [blame]
Matteo Scandoloa4285862020-12-01 18:10:10 -08001/*
2Copyright 2019 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
17package v1
18
19import (
20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21)
22
23// Rule is a tuple of APIGroups, APIVersion, and Resources.It is recommended
24// to make sure that all the tuple expansions are valid.
25type Rule struct {
26 // APIGroups is the API groups the resources belong to. '*' is all groups.
27 // If '*' is present, the length of the slice must be one.
28 // Required.
29 APIGroups []string `json:"apiGroups,omitempty" protobuf:"bytes,1,rep,name=apiGroups"`
30
31 // APIVersions is the API versions the resources belong to. '*' is all versions.
32 // If '*' is present, the length of the slice must be one.
33 // Required.
34 APIVersions []string `json:"apiVersions,omitempty" protobuf:"bytes,2,rep,name=apiVersions"`
35
36 // Resources is a list of resources this rule applies to.
37 //
38 // For example:
39 // 'pods' means pods.
40 // 'pods/log' means the log subresource of pods.
41 // '*' means all resources, but not subresources.
42 // 'pods/*' means all subresources of pods.
43 // '*/scale' means all scale subresources.
44 // '*/*' means all resources and their subresources.
45 //
46 // If wildcard is present, the validation rule will ensure resources do not
47 // overlap with each other.
48 //
49 // Depending on the enclosing object, subresources might not be allowed.
50 // Required.
51 Resources []string `json:"resources,omitempty" protobuf:"bytes,3,rep,name=resources"`
52
53 // scope specifies the scope of this rule.
54 // Valid values are "Cluster", "Namespaced", and "*"
55 // "Cluster" means that only cluster-scoped resources will match this rule.
56 // Namespace API objects are cluster-scoped.
57 // "Namespaced" means that only namespaced resources will match this rule.
58 // "*" means that there are no scope restrictions.
59 // Subresources match the scope of their parent resource.
60 // Default is "*".
61 //
62 // +optional
63 Scope *ScopeType `json:"scope,omitempty" protobuf:"bytes,4,rep,name=scope"`
64}
65
66type ScopeType string
67
68const (
69 // ClusterScope means that scope is limited to cluster-scoped objects.
70 // Namespace objects are cluster-scoped.
71 ClusterScope ScopeType = "Cluster"
72 // NamespacedScope means that scope is limited to namespaced objects.
73 NamespacedScope ScopeType = "Namespaced"
74 // AllScopes means that all scopes are included.
75 AllScopes ScopeType = "*"
76)
77
78type FailurePolicyType string
79
80const (
81 // Ignore means that an error calling the webhook is ignored.
82 Ignore FailurePolicyType = "Ignore"
83 // Fail means that an error calling the webhook causes the admission to fail.
84 Fail FailurePolicyType = "Fail"
85)
86
87// MatchPolicyType specifies the type of match policy
88type MatchPolicyType string
89
90const (
91 // Exact means requests should only be sent to the webhook if they exactly match a given rule
92 Exact MatchPolicyType = "Exact"
93 // Equivalent means requests should be sent to the webhook if they modify a resource listed in rules via another API group or version.
94 Equivalent MatchPolicyType = "Equivalent"
95)
96
97type SideEffectClass string
98
99const (
100 // SideEffectClassUnknown means that no information is known about the side effects of calling the webhook.
101 // If a request with the dry-run attribute would trigger a call to this webhook, the request will instead fail.
102 SideEffectClassUnknown SideEffectClass = "Unknown"
103 // SideEffectClassNone means that calling the webhook will have no side effects.
104 SideEffectClassNone SideEffectClass = "None"
105 // SideEffectClassSome means that calling the webhook will possibly have side effects.
106 // If a request with the dry-run attribute would trigger a call to this webhook, the request will instead fail.
107 SideEffectClassSome SideEffectClass = "Some"
108 // SideEffectClassNoneOnDryRun means that calling the webhook will possibly have side effects, but if the
109 // request being reviewed has the dry-run attribute, the side effects will be suppressed.
110 SideEffectClassNoneOnDryRun SideEffectClass = "NoneOnDryRun"
111)
112
113// +genclient
114// +genclient:nonNamespaced
115// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
116
117// ValidatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and object without changing it.
118type ValidatingWebhookConfiguration struct {
119 metav1.TypeMeta `json:",inline"`
120 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
121 // +optional
122 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
123 // Webhooks is a list of webhooks and the affected resources and operations.
124 // +optional
125 // +patchMergeKey=name
126 // +patchStrategy=merge
127 Webhooks []ValidatingWebhook `json:"webhooks,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,2,rep,name=Webhooks"`
128}
129
130// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
131
132// ValidatingWebhookConfigurationList is a list of ValidatingWebhookConfiguration.
133type ValidatingWebhookConfigurationList struct {
134 metav1.TypeMeta `json:",inline"`
135 // Standard list metadata.
136 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
137 // +optional
138 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
139 // List of ValidatingWebhookConfiguration.
140 Items []ValidatingWebhookConfiguration `json:"items" protobuf:"bytes,2,rep,name=items"`
141}
142
143// +genclient
144// +genclient:nonNamespaced
145// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
146
147// MutatingWebhookConfiguration describes the configuration of and admission webhook that accept or reject and may change the object.
148type MutatingWebhookConfiguration struct {
149 metav1.TypeMeta `json:",inline"`
150 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
151 // +optional
152 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
153 // Webhooks is a list of webhooks and the affected resources and operations.
154 // +optional
155 // +patchMergeKey=name
156 // +patchStrategy=merge
157 Webhooks []MutatingWebhook `json:"webhooks,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,2,rep,name=Webhooks"`
158}
159
160// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
161
162// MutatingWebhookConfigurationList is a list of MutatingWebhookConfiguration.
163type MutatingWebhookConfigurationList struct {
164 metav1.TypeMeta `json:",inline"`
165 // Standard list metadata.
166 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
167 // +optional
168 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
169 // List of MutatingWebhookConfiguration.
170 Items []MutatingWebhookConfiguration `json:"items" protobuf:"bytes,2,rep,name=items"`
171}
172
173// ValidatingWebhook describes an admission webhook and the resources and operations it applies to.
174type ValidatingWebhook struct {
175 // The name of the admission webhook.
176 // Name should be fully qualified, e.g., imagepolicy.kubernetes.io, where
177 // "imagepolicy" is the name of the webhook, and kubernetes.io is the name
178 // of the organization.
179 // Required.
180 Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
181
182 // ClientConfig defines how to communicate with the hook.
183 // Required
184 ClientConfig WebhookClientConfig `json:"clientConfig" protobuf:"bytes,2,opt,name=clientConfig"`
185
186 // Rules describes what operations on what resources/subresources the webhook cares about.
187 // The webhook cares about an operation if it matches _any_ Rule.
188 // However, in order to prevent ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks
189 // from putting the cluster in a state which cannot be recovered from without completely
190 // disabling the plugin, ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks are never called
191 // on admission requests for ValidatingWebhookConfiguration and MutatingWebhookConfiguration objects.
192 Rules []RuleWithOperations `json:"rules,omitempty" protobuf:"bytes,3,rep,name=rules"`
193
194 // FailurePolicy defines how unrecognized errors from the admission endpoint are handled -
195 // allowed values are Ignore or Fail. Defaults to Fail.
196 // +optional
197 FailurePolicy *FailurePolicyType `json:"failurePolicy,omitempty" protobuf:"bytes,4,opt,name=failurePolicy,casttype=FailurePolicyType"`
198
199 // matchPolicy defines how the "rules" list is used to match incoming requests.
200 // Allowed values are "Exact" or "Equivalent".
201 //
202 // - Exact: match a request only if it exactly matches a specified rule.
203 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
204 // but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
205 // a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
206 //
207 // - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
208 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
209 // and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
210 // a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
211 //
212 // Defaults to "Equivalent"
213 // +optional
214 MatchPolicy *MatchPolicyType `json:"matchPolicy,omitempty" protobuf:"bytes,9,opt,name=matchPolicy,casttype=MatchPolicyType"`
215
216 // NamespaceSelector decides whether to run the webhook on an object based
217 // on whether the namespace for that object matches the selector. If the
218 // object itself is a namespace, the matching is performed on
219 // object.metadata.labels. If the object is another cluster scoped resource,
220 // it never skips the webhook.
221 //
222 // For example, to run the webhook on any objects whose namespace is not
223 // associated with "runlevel" of "0" or "1"; you will set the selector as
224 // follows:
225 // "namespaceSelector": {
226 // "matchExpressions": [
227 // {
228 // "key": "runlevel",
229 // "operator": "NotIn",
230 // "values": [
231 // "0",
232 // "1"
233 // ]
234 // }
235 // ]
236 // }
237 //
238 // If instead you want to only run the webhook on any objects whose
239 // namespace is associated with the "environment" of "prod" or "staging";
240 // you will set the selector as follows:
241 // "namespaceSelector": {
242 // "matchExpressions": [
243 // {
244 // "key": "environment",
245 // "operator": "In",
246 // "values": [
247 // "prod",
248 // "staging"
249 // ]
250 // }
251 // ]
252 // }
253 //
254 // See
255 // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
256 // for more examples of label selectors.
257 //
258 // Default to the empty LabelSelector, which matches everything.
259 // +optional
260 NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,5,opt,name=namespaceSelector"`
261
262 // ObjectSelector decides whether to run the webhook based on if the
263 // object has matching labels. objectSelector is evaluated against both
264 // the oldObject and newObject that would be sent to the webhook, and
265 // is considered to match if either object matches the selector. A null
266 // object (oldObject in the case of create, or newObject in the case of
267 // delete) or an object that cannot have labels (like a
268 // DeploymentRollback or a PodProxyOptions object) is not considered to
269 // match.
270 // Use the object selector only if the webhook is opt-in, because end
271 // users may skip the admission webhook by setting the labels.
272 // Default to the empty LabelSelector, which matches everything.
273 // +optional
274 ObjectSelector *metav1.LabelSelector `json:"objectSelector,omitempty" protobuf:"bytes,10,opt,name=objectSelector"`
275
276 // SideEffects states whether this webhook has side effects.
277 // Acceptable values are: None, NoneOnDryRun (webhooks created via v1beta1 may also specify Some or Unknown).
278 // Webhooks with side effects MUST implement a reconciliation system, since a request may be
279 // rejected by a future step in the admission change and the side effects therefore need to be undone.
280 // Requests with the dryRun attribute will be auto-rejected if they match a webhook with
281 // sideEffects == Unknown or Some.
282 SideEffects *SideEffectClass `json:"sideEffects" protobuf:"bytes,6,opt,name=sideEffects,casttype=SideEffectClass"`
283
284 // TimeoutSeconds specifies the timeout for this webhook. After the timeout passes,
285 // the webhook call will be ignored or the API call will fail based on the
286 // failure policy.
287 // The timeout value must be between 1 and 30 seconds.
288 // Default to 10 seconds.
289 // +optional
290 TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty" protobuf:"varint,7,opt,name=timeoutSeconds"`
291
292 // AdmissionReviewVersions is an ordered list of preferred `AdmissionReview`
293 // versions the Webhook expects. API server will try to use first version in
294 // the list which it supports. If none of the versions specified in this list
295 // supported by API server, validation will fail for this object.
296 // If a persisted webhook configuration specifies allowed versions and does not
297 // include any versions known to the API Server, calls to the webhook will fail
298 // and be subject to the failure policy.
299 AdmissionReviewVersions []string `json:"admissionReviewVersions" protobuf:"bytes,8,rep,name=admissionReviewVersions"`
300}
301
302// MutatingWebhook describes an admission webhook and the resources and operations it applies to.
303type MutatingWebhook struct {
304 // The name of the admission webhook.
305 // Name should be fully qualified, e.g., imagepolicy.kubernetes.io, where
306 // "imagepolicy" is the name of the webhook, and kubernetes.io is the name
307 // of the organization.
308 // Required.
309 Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
310
311 // ClientConfig defines how to communicate with the hook.
312 // Required
313 ClientConfig WebhookClientConfig `json:"clientConfig" protobuf:"bytes,2,opt,name=clientConfig"`
314
315 // Rules describes what operations on what resources/subresources the webhook cares about.
316 // The webhook cares about an operation if it matches _any_ Rule.
317 // However, in order to prevent ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks
318 // from putting the cluster in a state which cannot be recovered from without completely
319 // disabling the plugin, ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks are never called
320 // on admission requests for ValidatingWebhookConfiguration and MutatingWebhookConfiguration objects.
321 Rules []RuleWithOperations `json:"rules,omitempty" protobuf:"bytes,3,rep,name=rules"`
322
323 // FailurePolicy defines how unrecognized errors from the admission endpoint are handled -
324 // allowed values are Ignore or Fail. Defaults to Fail.
325 // +optional
326 FailurePolicy *FailurePolicyType `json:"failurePolicy,omitempty" protobuf:"bytes,4,opt,name=failurePolicy,casttype=FailurePolicyType"`
327
328 // matchPolicy defines how the "rules" list is used to match incoming requests.
329 // Allowed values are "Exact" or "Equivalent".
330 //
331 // - Exact: match a request only if it exactly matches a specified rule.
332 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
333 // but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
334 // a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
335 //
336 // - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
337 // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
338 // and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
339 // a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
340 //
341 // Defaults to "Equivalent"
342 // +optional
343 MatchPolicy *MatchPolicyType `json:"matchPolicy,omitempty" protobuf:"bytes,9,opt,name=matchPolicy,casttype=MatchPolicyType"`
344
345 // NamespaceSelector decides whether to run the webhook on an object based
346 // on whether the namespace for that object matches the selector. If the
347 // object itself is a namespace, the matching is performed on
348 // object.metadata.labels. If the object is another cluster scoped resource,
349 // it never skips the webhook.
350 //
351 // For example, to run the webhook on any objects whose namespace is not
352 // associated with "runlevel" of "0" or "1"; you will set the selector as
353 // follows:
354 // "namespaceSelector": {
355 // "matchExpressions": [
356 // {
357 // "key": "runlevel",
358 // "operator": "NotIn",
359 // "values": [
360 // "0",
361 // "1"
362 // ]
363 // }
364 // ]
365 // }
366 //
367 // If instead you want to only run the webhook on any objects whose
368 // namespace is associated with the "environment" of "prod" or "staging";
369 // you will set the selector as follows:
370 // "namespaceSelector": {
371 // "matchExpressions": [
372 // {
373 // "key": "environment",
374 // "operator": "In",
375 // "values": [
376 // "prod",
377 // "staging"
378 // ]
379 // }
380 // ]
381 // }
382 //
383 // See
384 // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
385 // for more examples of label selectors.
386 //
387 // Default to the empty LabelSelector, which matches everything.
388 // +optional
389 NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty" protobuf:"bytes,5,opt,name=namespaceSelector"`
390
391 // ObjectSelector decides whether to run the webhook based on if the
392 // object has matching labels. objectSelector is evaluated against both
393 // the oldObject and newObject that would be sent to the webhook, and
394 // is considered to match if either object matches the selector. A null
395 // object (oldObject in the case of create, or newObject in the case of
396 // delete) or an object that cannot have labels (like a
397 // DeploymentRollback or a PodProxyOptions object) is not considered to
398 // match.
399 // Use the object selector only if the webhook is opt-in, because end
400 // users may skip the admission webhook by setting the labels.
401 // Default to the empty LabelSelector, which matches everything.
402 // +optional
403 ObjectSelector *metav1.LabelSelector `json:"objectSelector,omitempty" protobuf:"bytes,11,opt,name=objectSelector"`
404
405 // SideEffects states whether this webhook has side effects.
406 // Acceptable values are: None, NoneOnDryRun (webhooks created via v1beta1 may also specify Some or Unknown).
407 // Webhooks with side effects MUST implement a reconciliation system, since a request may be
408 // rejected by a future step in the admission change and the side effects therefore need to be undone.
409 // Requests with the dryRun attribute will be auto-rejected if they match a webhook with
410 // sideEffects == Unknown or Some.
411 SideEffects *SideEffectClass `json:"sideEffects" protobuf:"bytes,6,opt,name=sideEffects,casttype=SideEffectClass"`
412
413 // TimeoutSeconds specifies the timeout for this webhook. After the timeout passes,
414 // the webhook call will be ignored or the API call will fail based on the
415 // failure policy.
416 // The timeout value must be between 1 and 30 seconds.
417 // Default to 10 seconds.
418 // +optional
419 TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty" protobuf:"varint,7,opt,name=timeoutSeconds"`
420
421 // AdmissionReviewVersions is an ordered list of preferred `AdmissionReview`
422 // versions the Webhook expects. API server will try to use first version in
423 // the list which it supports. If none of the versions specified in this list
424 // supported by API server, validation will fail for this object.
425 // If a persisted webhook configuration specifies allowed versions and does not
426 // include any versions known to the API Server, calls to the webhook will fail
427 // and be subject to the failure policy.
428 AdmissionReviewVersions []string `json:"admissionReviewVersions" protobuf:"bytes,8,rep,name=admissionReviewVersions"`
429
430 // reinvocationPolicy indicates whether this webhook should be called multiple times as part of a single admission evaluation.
431 // Allowed values are "Never" and "IfNeeded".
432 //
433 // Never: the webhook will not be called more than once in a single admission evaluation.
434 //
435 // IfNeeded: the webhook will be called at least one additional time as part of the admission evaluation
436 // if the object being admitted is modified by other admission plugins after the initial webhook call.
437 // Webhooks that specify this option *must* be idempotent, able to process objects they previously admitted.
438 // Note:
439 // * the number of additional invocations is not guaranteed to be exactly one.
440 // * if additional invocations result in further modifications to the object, webhooks are not guaranteed to be invoked again.
441 // * webhooks that use this option may be reordered to minimize the number of additional invocations.
442 // * to validate an object after all mutations are guaranteed complete, use a validating admission webhook instead.
443 //
444 // Defaults to "Never".
445 // +optional
446 ReinvocationPolicy *ReinvocationPolicyType `json:"reinvocationPolicy,omitempty" protobuf:"bytes,10,opt,name=reinvocationPolicy,casttype=ReinvocationPolicyType"`
447}
448
449// ReinvocationPolicyType specifies what type of policy the admission hook uses.
450type ReinvocationPolicyType string
451
452const (
453 // NeverReinvocationPolicy indicates that the webhook must not be called more than once in a
454 // single admission evaluation.
455 NeverReinvocationPolicy ReinvocationPolicyType = "Never"
456 // IfNeededReinvocationPolicy indicates that the webhook may be called at least one
457 // additional time as part of the admission evaluation if the object being admitted is
458 // modified by other admission plugins after the initial webhook call.
459 IfNeededReinvocationPolicy ReinvocationPolicyType = "IfNeeded"
460)
461
462// RuleWithOperations is a tuple of Operations and Resources. It is recommended to make
463// sure that all the tuple expansions are valid.
464type RuleWithOperations struct {
465 // Operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or *
466 // for all of those operations and any future admission operations that are added.
467 // If '*' is present, the length of the slice must be one.
468 // Required.
469 Operations []OperationType `json:"operations,omitempty" protobuf:"bytes,1,rep,name=operations,casttype=OperationType"`
470 // Rule is embedded, it describes other criteria of the rule, like
471 // APIGroups, APIVersions, Resources, etc.
472 Rule `json:",inline" protobuf:"bytes,2,opt,name=rule"`
473}
474
475type OperationType string
476
477// The constants should be kept in sync with those defined in k8s.io/kubernetes/pkg/admission/interface.go.
478const (
479 OperationAll OperationType = "*"
480 Create OperationType = "CREATE"
481 Update OperationType = "UPDATE"
482 Delete OperationType = "DELETE"
483 Connect OperationType = "CONNECT"
484)
485
486// WebhookClientConfig contains the information to make a TLS
487// connection with the webhook
488type WebhookClientConfig struct {
489 // `url` gives the location of the webhook, in standard URL form
490 // (`scheme://host:port/path`). Exactly one of `url` or `service`
491 // must be specified.
492 //
493 // The `host` should not refer to a service running in the cluster; use
494 // the `service` field instead. The host might be resolved via external
495 // DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
496 // in-cluster DNS as that would be a layering violation). `host` may
497 // also be an IP address.
498 //
499 // Please note that using `localhost` or `127.0.0.1` as a `host` is
500 // risky unless you take great care to run this webhook on all hosts
501 // which run an apiserver which might need to make calls to this
502 // webhook. Such installs are likely to be non-portable, i.e., not easy
503 // to turn up in a new cluster.
504 //
505 // The scheme must be "https"; the URL must begin with "https://".
506 //
507 // A path is optional, and if present may be any string permissible in
508 // a URL. You may use the path to pass an arbitrary string to the
509 // webhook, for example, a cluster identifier.
510 //
511 // Attempting to use a user or basic auth e.g. "user:password@" is not
512 // allowed. Fragments ("#...") and query parameters ("?...") are not
513 // allowed, either.
514 //
515 // +optional
516 URL *string `json:"url,omitempty" protobuf:"bytes,3,opt,name=url"`
517
518 // `service` is a reference to the service for this webhook. Either
519 // `service` or `url` must be specified.
520 //
521 // If the webhook is running within the cluster, then you should use `service`.
522 //
523 // +optional
524 Service *ServiceReference `json:"service,omitempty" protobuf:"bytes,1,opt,name=service"`
525
526 // `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.
527 // If unspecified, system trust roots on the apiserver are used.
528 // +optional
529 CABundle []byte `json:"caBundle,omitempty" protobuf:"bytes,2,opt,name=caBundle"`
530}
531
532// ServiceReference holds a reference to Service.legacy.k8s.io
533type ServiceReference struct {
534 // `namespace` is the namespace of the service.
535 // Required
536 Namespace string `json:"namespace" protobuf:"bytes,1,opt,name=namespace"`
537 // `name` is the name of the service.
538 // Required
539 Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
540
541 // `path` is an optional URL path which will be sent in any request to
542 // this service.
543 // +optional
544 Path *string `json:"path,omitempty" protobuf:"bytes,3,opt,name=path"`
545
546 // If specified, the port on the service that hosting webhook.
547 // Default to 443 for backward compatibility.
548 // `port` should be a valid port number (1-65535, inclusive).
549 // +optional
550 Port *int32 `json:"port,omitempty" protobuf:"varint,4,opt,name=port"`
551}