generated.proto 66 KB

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