generated.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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.v1alpha1;
  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/v1alpha1";
  22. // MatchResources decides whether to run the admission control policy on an object based
  23. // on whether it meets the match criteria.
  24. // The exclude rules take precedence over include rules (if a resource matches both, it is excluded)
  25. // +structType=atomic
  26. message MatchResources {
  27. // NamespaceSelector decides whether to run the admission control policy on an object based
  28. // on whether the namespace for that object matches the selector. If the
  29. // object itself is a namespace, the matching is performed on
  30. // object.metadata.labels. If the object is another cluster scoped resource,
  31. // it never skips the policy.
  32. //
  33. // For example, to run the webhook on any objects whose namespace is not
  34. // associated with "runlevel" of "0" or "1"; you will set the selector as
  35. // follows:
  36. // "namespaceSelector": {
  37. // "matchExpressions": [
  38. // {
  39. // "key": "runlevel",
  40. // "operator": "NotIn",
  41. // "values": [
  42. // "0",
  43. // "1"
  44. // ]
  45. // }
  46. // ]
  47. // }
  48. //
  49. // If instead you want to only run the policy on any objects whose
  50. // namespace is associated with the "environment" of "prod" or "staging";
  51. // you will set the selector as follows:
  52. // "namespaceSelector": {
  53. // "matchExpressions": [
  54. // {
  55. // "key": "environment",
  56. // "operator": "In",
  57. // "values": [
  58. // "prod",
  59. // "staging"
  60. // ]
  61. // }
  62. // ]
  63. // }
  64. //
  65. // See
  66. // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
  67. // for more examples of label selectors.
  68. //
  69. // Default to the empty LabelSelector, which matches everything.
  70. // +optional
  71. optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector namespaceSelector = 1;
  72. // ObjectSelector decides whether to run the validation based on if the
  73. // object has matching labels. objectSelector is evaluated against both
  74. // the oldObject and newObject that would be sent to the cel validation, and
  75. // is considered to match if either object matches the selector. A null
  76. // object (oldObject in the case of create, or newObject in the case of
  77. // delete) or an object that cannot have labels (like a
  78. // DeploymentRollback or a PodProxyOptions object) is not considered to
  79. // match.
  80. // Use the object selector only if the webhook is opt-in, because end
  81. // users may skip the admission webhook by setting the labels.
  82. // Default to the empty LabelSelector, which matches everything.
  83. // +optional
  84. optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector objectSelector = 2;
  85. // ResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy matches.
  86. // The policy cares about an operation if it matches _any_ Rule.
  87. // +listType=atomic
  88. // +optional
  89. repeated NamedRuleWithOperations resourceRules = 3;
  90. // ExcludeResourceRules describes what operations on what resources/subresources the ValidatingAdmissionPolicy should not care about.
  91. // The exclude rules take precedence over include rules (if a resource matches both, it is excluded)
  92. // +listType=atomic
  93. // +optional
  94. repeated NamedRuleWithOperations excludeResourceRules = 4;
  95. // matchPolicy defines how the "MatchResources" list is used to match incoming requests.
  96. // Allowed values are "Exact" or "Equivalent".
  97. //
  98. // - Exact: match a request only if it exactly matches a specified rule.
  99. // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
  100. // but "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
  101. // a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the ValidatingAdmissionPolicy.
  102. //
  103. // - Equivalent: match a request if modifies a resource listed in rules, even via another API group or version.
  104. // For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1,
  105. // and "rules" only included `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]`,
  106. // a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the ValidatingAdmissionPolicy.
  107. //
  108. // Defaults to "Equivalent"
  109. // +optional
  110. optional string matchPolicy = 7;
  111. }
  112. // NamedRuleWithOperations is a tuple of Operations and Resources with ResourceNames.
  113. // +structType=atomic
  114. message NamedRuleWithOperations {
  115. // ResourceNames is an optional white list of names that the rule applies to. An empty set means that everything is allowed.
  116. // +listType=atomic
  117. // +optional
  118. repeated string resourceNames = 1;
  119. // RuleWithOperations is a tuple of Operations and Resources.
  120. optional k8s.io.api.admissionregistration.v1.RuleWithOperations ruleWithOperations = 2;
  121. }
  122. // ParamKind is a tuple of Group Kind and Version.
  123. // +structType=atomic
  124. message ParamKind {
  125. // APIVersion is the API group version the resources belong to.
  126. // In format of "group/version".
  127. // Required.
  128. optional string apiVersion = 1;
  129. // Kind is the API kind the resources belong to.
  130. // Required.
  131. optional string kind = 2;
  132. }
  133. // ParamRef references a parameter resource
  134. // +structType=atomic
  135. message ParamRef {
  136. // Name of the resource being referenced.
  137. optional string name = 1;
  138. // Namespace of the referenced resource.
  139. // Should be empty for the cluster-scoped resources
  140. // +optional
  141. optional string namespace = 2;
  142. }
  143. // ValidatingAdmissionPolicy describes the definition of an admission validation policy that accepts or rejects an object without changing it.
  144. message ValidatingAdmissionPolicy {
  145. // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
  146. // +optional
  147. optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
  148. // Specification of the desired behavior of the ValidatingAdmissionPolicy.
  149. optional ValidatingAdmissionPolicySpec spec = 2;
  150. }
  151. // ValidatingAdmissionPolicyBinding binds the ValidatingAdmissionPolicy with paramerized resources.
  152. // ValidatingAdmissionPolicyBinding and parameter CRDs together define how cluster administrators configure policies for clusters.
  153. message ValidatingAdmissionPolicyBinding {
  154. // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
  155. // +optional
  156. optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
  157. // Specification of the desired behavior of the ValidatingAdmissionPolicyBinding.
  158. optional ValidatingAdmissionPolicyBindingSpec spec = 2;
  159. }
  160. // ValidatingAdmissionPolicyBindingList is a list of ValidatingAdmissionPolicyBinding.
  161. message ValidatingAdmissionPolicyBindingList {
  162. // Standard list metadata.
  163. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
  164. // +optional
  165. optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
  166. // List of PolicyBinding.
  167. repeated ValidatingAdmissionPolicyBinding items = 2;
  168. }
  169. // ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding.
  170. message ValidatingAdmissionPolicyBindingSpec {
  171. // PolicyName references a ValidatingAdmissionPolicy name which the ValidatingAdmissionPolicyBinding binds to.
  172. // If the referenced resource does not exist, this binding is considered invalid and will be ignored
  173. // Required.
  174. optional string policyName = 1;
  175. // ParamRef specifies the parameter resource used to configure the admission control policy.
  176. // It should point to a resource of the type specified in ParamKind of the bound ValidatingAdmissionPolicy.
  177. // 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.
  178. // +optional
  179. optional ParamRef paramRef = 2;
  180. // MatchResources declares what resources match this binding and will be validated by it.
  181. // Note that this is intersected with the policy's matchConstraints, so only requests that are matched by the policy can be selected by this.
  182. // If this is unset, all resources matched by the policy are validated by this binding
  183. // 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.
  184. // Note that this is differs from ValidatingAdmissionPolicy matchConstraints, where resourceRules are required.
  185. // +optional
  186. optional MatchResources matchResources = 3;
  187. }
  188. // ValidatingAdmissionPolicyList is a list of ValidatingAdmissionPolicy.
  189. message ValidatingAdmissionPolicyList {
  190. // Standard list metadata.
  191. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
  192. // +optional
  193. optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
  194. // List of ValidatingAdmissionPolicy.
  195. repeated ValidatingAdmissionPolicy items = 2;
  196. }
  197. // ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy.
  198. message ValidatingAdmissionPolicySpec {
  199. // ParamKind specifies the kind of resources used to parameterize this policy.
  200. // If absent, there are no parameters for this policy and the param CEL variable will not be provided to validation expressions.
  201. // If ParamKind refers to a non-existent kind, this policy definition is mis-configured and the FailurePolicy is applied.
  202. // If paramKind is specified but paramRef is unset in ValidatingAdmissionPolicyBinding, the params variable will be null.
  203. // +optional
  204. optional ParamKind paramKind = 1;
  205. // MatchConstraints specifies what resources this policy is designed to validate.
  206. // The AdmissionPolicy cares about a request if it matches _all_ Constraints.
  207. // However, in order to prevent clusters from being put into an unstable state that cannot be recovered from via the API
  208. // ValidatingAdmissionPolicy cannot match ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding.
  209. // Required.
  210. optional MatchResources matchConstraints = 2;
  211. // Validations contain CEL expressions which is used to apply the validation.
  212. // A minimum of one validation is required for a policy definition.
  213. // +listType=atomic
  214. // Required.
  215. repeated Validation validations = 3;
  216. // FailurePolicy defines how to handle failures for the admission policy.
  217. // Failures can occur from invalid or mis-configured policy definitions or bindings.
  218. // A policy is invalid if spec.paramKind refers to a non-existent Kind.
  219. // A binding is invalid if spec.paramRef.name refers to a non-existent resource.
  220. // Allowed values are Ignore or Fail. Defaults to Fail.
  221. // +optional
  222. optional string failurePolicy = 4;
  223. }
  224. // Validation specifies the CEL expression which is used to apply the validation.
  225. message Validation {
  226. // Expression represents the expression which will be evaluated by CEL.
  227. // ref: https://github.com/google/cel-spec
  228. // CEL expressions have access to the contents of the Admission request/response, organized into CEL variables as well as some other useful variables:
  229. //
  230. // 'object' - The object from the incoming request. The value is null for DELETE requests.
  231. // 'oldObject' - The existing object. The value is null for CREATE requests.
  232. // 'request' - Attributes of the admission request([ref](/pkg/apis/admission/types.go#AdmissionRequest)).
  233. // 'params' - Parameter resource referred to by the policy binding being evaluated. Only populated if the policy has a ParamKind.
  234. //
  235. // The `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the
  236. // object. No other metadata properties are accessible.
  237. //
  238. // Only property names of the form `[a-zA-Z_.-/][a-zA-Z0-9_.-/]*` are accessible.
  239. // Accessible property names are escaped according to the following rules when accessed in the expression:
  240. // - '__' escapes to '__underscores__'
  241. // - '.' escapes to '__dot__'
  242. // - '-' escapes to '__dash__'
  243. // - '/' escapes to '__slash__'
  244. // - Property names that exactly match a CEL RESERVED keyword escape to '__{keyword}__'. The keywords are:
  245. // "true", "false", "null", "in", "as", "break", "const", "continue", "else", "for", "function", "if",
  246. // "import", "let", "loop", "package", "namespace", "return".
  247. // Examples:
  248. // - Expression accessing a property named "namespace": {"Expression": "object.__namespace__ > 0"}
  249. // - Expression accessing a property named "x-prop": {"Expression": "object.x__dash__prop > 0"}
  250. // - Expression accessing a property named "redact__d": {"Expression": "object.redact__underscores__d > 0"}
  251. //
  252. // Equality on arrays with list type of 'set' or 'map' ignores element order, i.e. [1, 2] == [2, 1].
  253. // Concatenation on arrays with x-kubernetes-list-type use the semantics of the list type:
  254. // - 'set': `X + Y` performs a union where the array positions of all elements in `X` are preserved and
  255. // non-intersecting elements in `Y` are appended, retaining their partial order.
  256. // - 'map': `X + Y` performs a merge where the array positions of all keys in `X` are preserved but the values
  257. // are overwritten by values in `Y` when the key sets of `X` and `Y` intersect. Elements in `Y` with
  258. // non-intersecting keys are appended, retaining their partial order.
  259. // Required.
  260. optional string Expression = 1;
  261. // Message represents the message displayed when validation fails. The message is required if the Expression contains
  262. // line breaks. The message must not contain line breaks.
  263. // If unset, the message is "failed rule: {Rule}".
  264. // e.g. "must be a URL with the host matching spec.host"
  265. // If the Expression contains line breaks. Message is required.
  266. // The message must not contain line breaks.
  267. // If unset, the message is "failed Expression: {Expression}".
  268. // +optional
  269. optional string message = 2;
  270. // Reason represents a machine-readable description of why this validation failed.
  271. // If this is the first validation in the list to fail, this reason, as well as the
  272. // corresponding HTTP response code, are used in the
  273. // HTTP response to the client.
  274. // The currently supported reasons are: "Unauthorized", "Forbidden", "Invalid", "RequestEntityTooLarge".
  275. // If not set, StatusReasonInvalid is used in the response to the client.
  276. // +optional
  277. optional string reason = 3;
  278. }