1/* 2Copyright 2019 The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17package v1 18 19import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 "k8s.io/apimachinery/pkg/runtime" 22 "k8s.io/apimachinery/pkg/types" 23) 24 25// ConversionStrategyType describes different conversion types. 26type ConversionStrategyType string 27 28const ( 29 // KubeAPIApprovedAnnotation is an annotation that must be set to create a CRD for the k8s.io, *.k8s.io, kubernetes.io, or *.kubernetes.io namespaces. 30 // The value should be a link to a URL where the current spec was approved, so updates to the spec should also update the URL. 31 // If the API is unapproved, you may set the annotation to a string starting with `"unapproved"`. For instance, `"unapproved, temporarily squatting"` or `"unapproved, experimental-only"`. This is discouraged. 32 KubeAPIApprovedAnnotation = "api-approved.kubernetes.io" 33 34 // NoneConverter is a converter that only sets apiversion of the CR and leave everything else unchanged. 35 NoneConverter ConversionStrategyType = "None" 36 // WebhookConverter is a converter that calls to an external webhook to convert the CR. 37 WebhookConverter ConversionStrategyType = "Webhook" 38) 39 40// CustomResourceDefinitionSpec describes how a user wants their resource to appear 41type CustomResourceDefinitionSpec struct { 42 // group is the API group of the defined custom resource. 43 // The custom resources are served under `/apis/<group>/...`. 44 // Must match the name of the CustomResourceDefinition (in the form `<names.plural>.<group>`). 45 Group string `json:"group" protobuf:"bytes,1,opt,name=group"` 46 // names specify the resource and kind names for the custom resource. 47 Names CustomResourceDefinitionNames `json:"names" protobuf:"bytes,3,opt,name=names"` 48 // scope indicates whether the defined custom resource is cluster- or namespace-scoped. 49 // Allowed values are `Cluster` and `Namespaced`. 50 Scope ResourceScope `json:"scope" protobuf:"bytes,4,opt,name=scope,casttype=ResourceScope"` 51 // versions is the list of all API versions of the defined custom resource. 52 // Version names are used to compute the order in which served versions are listed in API discovery. 53 // If the version string is "kube-like", it will sort above non "kube-like" version strings, which are ordered 54 // lexicographically. "Kube-like" versions start with a "v", then are followed by a number (the major version), 55 // then optionally the string "alpha" or "beta" and another number (the minor version). These are sorted first 56 // by GA > beta > alpha (where GA is a version with no suffix such as beta or alpha), and then by comparing 57 // major version, then minor version. An example sorted list of versions: 58 // v10, v2, v1, v11beta2, v10beta3, v3beta1, v12alpha1, v11alpha2, foo1, foo10. 59 Versions []CustomResourceDefinitionVersion `json:"versions" protobuf:"bytes,7,rep,name=versions"` 60 61 // conversion defines conversion settings for the CRD. 62 // +optional 63 Conversion *CustomResourceConversion `json:"conversion,omitempty" protobuf:"bytes,9,opt,name=conversion"` 64 65 // preserveUnknownFields indicates that object fields which are not specified 66 // in the OpenAPI schema should be preserved when persisting to storage. 67 // apiVersion, kind, metadata and known fields inside metadata are always preserved. 68 // This field is deprecated in favor of setting `x-preserve-unknown-fields` to true in `spec.versions[*].schema.openAPIV3Schema`. 69 // See https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#pruning-versus-preserving-unknown-fields for details. 70 // +optional 71 PreserveUnknownFields bool `json:"preserveUnknownFields,omitempty" protobuf:"varint,10,opt,name=preserveUnknownFields"` 72} 73 74// CustomResourceConversion describes how to convert different versions of a CR. 75type CustomResourceConversion struct { 76 // strategy specifies how custom resources are converted between versions. Allowed values are: 77 // - `None`: The converter only change the apiVersion and would not touch any other field in the custom resource. 78 // - `Webhook`: API Server will call to an external webhook to do the conversion. Additional information 79 // is needed for this option. This requires spec.preserveUnknownFields to be false, and spec.conversion.webhook to be set. 80 Strategy ConversionStrategyType `json:"strategy" protobuf:"bytes,1,name=strategy"` 81 82 // webhook describes how to call the conversion webhook. Required when `strategy` is set to `Webhook`. 83 // +optional 84 Webhook *WebhookConversion `json:"webhook,omitempty" protobuf:"bytes,2,opt,name=webhook"` 85} 86 87// WebhookConversion describes how to call a conversion webhook 88type WebhookConversion struct { 89 // clientConfig is the instructions for how to call the webhook if strategy is `Webhook`. 90 // +optional 91 ClientConfig *WebhookClientConfig `json:"clientConfig,omitempty" protobuf:"bytes,2,name=clientConfig"` 92 93 // conversionReviewVersions is an ordered list of preferred `ConversionReview` 94 // versions the Webhook expects. The API server will use the first version in 95 // the list which it supports. If none of the versions specified in this list 96 // are supported by API server, conversion will fail for the custom resource. 97 // If a persisted Webhook configuration specifies allowed versions and does not 98 // include any versions known to the API Server, calls to the webhook will fail. 99 ConversionReviewVersions []string `json:"conversionReviewVersions" protobuf:"bytes,3,rep,name=conversionReviewVersions"` 100} 101 102// WebhookClientConfig contains the information to make a TLS connection with the webhook. 103type WebhookClientConfig struct { 104 // url gives the location of the webhook, in standard URL form 105 // (`scheme://host:port/path`). Exactly one of `url` or `service` 106 // must be specified. 107 // 108 // The `host` should not refer to a service running in the cluster; use 109 // the `service` field instead. The host might be resolved via external 110 // DNS in some apiservers (e.g., `kube-apiserver` cannot resolve 111 // in-cluster DNS as that would be a layering violation). `host` may 112 // also be an IP address. 113 // 114 // Please note that using `localhost` or `127.0.0.1` as a `host` is 115 // risky unless you take great care to run this webhook on all hosts 116 // which run an apiserver which might need to make calls to this 117 // webhook. Such installs are likely to be non-portable, i.e., not easy 118 // to turn up in a new cluster. 119 // 120 // The scheme must be "https"; the URL must begin with "https://". 121 // 122 // A path is optional, and if present may be any string permissible in 123 // a URL. You may use the path to pass an arbitrary string to the 124 // webhook, for example, a cluster identifier. 125 // 126 // Attempting to use a user or basic auth e.g. "user:password@" is not 127 // allowed. Fragments ("#...") and query parameters ("?...") are not 128 // allowed, either. 129 // 130 // +optional 131 URL *string `json:"url,omitempty" protobuf:"bytes,3,opt,name=url"` 132 133 // service is a reference to the service for this webhook. Either 134 // service or url must be specified. 135 // 136 // If the webhook is running within the cluster, then you should use `service`. 137 // 138 // +optional 139 Service *ServiceReference `json:"service,omitempty" protobuf:"bytes,1,opt,name=service"` 140 141 // caBundle is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. 142 // If unspecified, system trust roots on the apiserver are used. 143 // +optional 144 CABundle []byte `json:"caBundle,omitempty" protobuf:"bytes,2,opt,name=caBundle"` 145} 146 147// ServiceReference holds a reference to Service.legacy.k8s.io 148type ServiceReference struct { 149 // namespace is the namespace of the service. 150 // Required 151 Namespace string `json:"namespace" protobuf:"bytes,1,opt,name=namespace"` 152 // name is the name of the service. 153 // Required 154 Name string `json:"name" protobuf:"bytes,2,opt,name=name"` 155 156 // path is an optional URL path at which the webhook will be contacted. 157 // +optional 158 Path *string `json:"path,omitempty" protobuf:"bytes,3,opt,name=path"` 159 160 // port is an optional service port at which the webhook will be contacted. 161 // `port` should be a valid port number (1-65535, inclusive). 162 // Defaults to 443 for backward compatibility. 163 // +optional 164 Port *int32 `json:"port,omitempty" protobuf:"varint,4,opt,name=port"` 165} 166 167// CustomResourceDefinitionVersion describes a version for CRD. 168type CustomResourceDefinitionVersion struct { 169 // name is the version name, e.g. “v1”, “v2beta1”, etc. 170 // The custom resources are served under this version at `/apis/<group>/<version>/...` if `served` is true. 171 Name string `json:"name" protobuf:"bytes,1,opt,name=name"` 172 // served is a flag enabling/disabling this version from being served via REST APIs 173 Served bool `json:"served" protobuf:"varint,2,opt,name=served"` 174 // storage indicates this version should be used when persisting custom resources to storage. 175 // There must be exactly one version with storage=true. 176 Storage bool `json:"storage" protobuf:"varint,3,opt,name=storage"` 177 // deprecated indicates this version of the custom resource API is deprecated. 178 // When set to true, API requests to this version receive a warning header in the server response. 179 // Defaults to false. 180 // +optional 181 Deprecated bool `json:"deprecated,omitempty" protobuf:"varint,7,opt,name=deprecated"` 182 // deprecationWarning overrides the default warning returned to API clients. 183 // May only be set when `deprecated` is true. 184 // The default warning indicates this version is deprecated and recommends use 185 // of the newest served version of equal or greater stability, if one exists. 186 // +optional 187 DeprecationWarning *string `json:"deprecationWarning,omitempty" protobuf:"bytes,8,opt,name=deprecationWarning"` 188 // schema describes the schema used for validation, pruning, and defaulting of this version of the custom resource. 189 // +optional 190 Schema *CustomResourceValidation `json:"schema,omitempty" protobuf:"bytes,4,opt,name=schema"` 191 // subresources specify what subresources this version of the defined custom resource have. 192 // +optional 193 Subresources *CustomResourceSubresources `json:"subresources,omitempty" protobuf:"bytes,5,opt,name=subresources"` 194 // additionalPrinterColumns specifies additional columns returned in Table output. 195 // See https://kubernetes.io/docs/reference/using-api/api-concepts/#receiving-resources-as-tables for details. 196 // If no columns are specified, a single column displaying the age of the custom resource is used. 197 // +optional 198 AdditionalPrinterColumns []CustomResourceColumnDefinition `json:"additionalPrinterColumns,omitempty" protobuf:"bytes,6,rep,name=additionalPrinterColumns"` 199} 200 201// CustomResourceColumnDefinition specifies a column for server side printing. 202type CustomResourceColumnDefinition struct { 203 // name is a human readable name for the column. 204 Name string `json:"name" protobuf:"bytes,1,opt,name=name"` 205 // type is an OpenAPI type definition for this column. 206 // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details. 207 Type string `json:"type" protobuf:"bytes,2,opt,name=type"` 208 // format is an optional OpenAPI type definition for this column. The 'name' format is applied 209 // to the primary identifier column to assist in clients identifying column is the resource name. 210 // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for details. 211 // +optional 212 Format string `json:"format,omitempty" protobuf:"bytes,3,opt,name=format"` 213 // description is a human readable description of this column. 214 // +optional 215 Description string `json:"description,omitempty" protobuf:"bytes,4,opt,name=description"` 216 // priority is an integer defining the relative importance of this column compared to others. Lower 217 // numbers are considered higher priority. Columns that may be omitted in limited space scenarios 218 // should be given a priority greater than 0. 219 // +optional 220 Priority int32 `json:"priority,omitempty" protobuf:"bytes,5,opt,name=priority"` 221 // jsonPath is a simple JSON path (i.e. with array notation) which is evaluated against 222 // each custom resource to produce the value for this column. 223 JSONPath string `json:"jsonPath" protobuf:"bytes,6,opt,name=jsonPath"` 224} 225 226// CustomResourceDefinitionNames indicates the names to serve this CustomResourceDefinition 227type CustomResourceDefinitionNames struct { 228 // plural is the plural name of the resource to serve. 229 // The custom resources are served under `/apis/<group>/<version>/.../<plural>`. 230 // Must match the name of the CustomResourceDefinition (in the form `<names.plural>.<group>`). 231 // Must be all lowercase. 232 Plural string `json:"plural" protobuf:"bytes,1,opt,name=plural"` 233 // singular is the singular name of the resource. It must be all lowercase. Defaults to lowercased `kind`. 234 // +optional 235 Singular string `json:"singular,omitempty" protobuf:"bytes,2,opt,name=singular"` 236 // shortNames are short names for the resource, exposed in API discovery documents, 237 // and used by clients to support invocations like `kubectl get <shortname>`. 238 // It must be all lowercase. 239 // +optional 240 ShortNames []string `json:"shortNames,omitempty" protobuf:"bytes,3,opt,name=shortNames"` 241 // kind is the serialized kind of the resource. It is normally CamelCase and singular. 242 // Custom resource instances will use this value as the `kind` attribute in API calls. 243 Kind string `json:"kind" protobuf:"bytes,4,opt,name=kind"` 244 // listKind is the serialized kind of the list for this resource. Defaults to "`kind`List". 245 // +optional 246 ListKind string `json:"listKind,omitempty" protobuf:"bytes,5,opt,name=listKind"` 247 // categories is a list of grouped resources this custom resource belongs to (e.g. 'all'). 248 // This is published in API discovery documents, and used by clients to support invocations like 249 // `kubectl get all`. 250 // +optional 251 Categories []string `json:"categories,omitempty" protobuf:"bytes,6,rep,name=categories"` 252} 253 254// ResourceScope is an enum defining the different scopes available to a custom resource 255type ResourceScope string 256 257const ( 258 ClusterScoped ResourceScope = "Cluster" 259 NamespaceScoped ResourceScope = "Namespaced" 260) 261 262type ConditionStatus string 263 264// These are valid condition statuses. "ConditionTrue" means a resource is in the condition. 265// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes 266// can't decide if a resource is in the condition or not. In the future, we could add other 267// intermediate conditions, e.g. ConditionDegraded. 268const ( 269 ConditionTrue ConditionStatus = "True" 270 ConditionFalse ConditionStatus = "False" 271 ConditionUnknown ConditionStatus = "Unknown" 272) 273 274// CustomResourceDefinitionConditionType is a valid value for CustomResourceDefinitionCondition.Type 275type CustomResourceDefinitionConditionType string 276 277const ( 278 // Established means that the resource has become active. A resource is established when all names are 279 // accepted without a conflict for the first time. A resource stays established until deleted, even during 280 // a later NamesAccepted due to changed names. Note that not all names can be changed. 281 Established CustomResourceDefinitionConditionType = "Established" 282 // NamesAccepted means the names chosen for this CustomResourceDefinition do not conflict with others in 283 // the group and are therefore accepted. 284 NamesAccepted CustomResourceDefinitionConditionType = "NamesAccepted" 285 // NonStructuralSchema means that one or more OpenAPI schema is not structural. 286 // 287 // A schema is structural if it specifies types for all values, with the only exceptions of those with 288 // - x-kubernetes-int-or-string: true — for fields which can be integer or string 289 // - x-kubernetes-preserve-unknown-fields: true — for raw, unspecified JSON values 290 // and there is no type, additionalProperties, default, nullable or x-kubernetes-* vendor extenions 291 // specified under allOf, anyOf, oneOf or not. 292 // 293 // Non-structural schemas will not be allowed anymore in v1 API groups. Moreover, new features will not be 294 // available for non-structural CRDs: 295 // - pruning 296 // - defaulting 297 // - read-only 298 // - OpenAPI publishing 299 // - webhook conversion 300 NonStructuralSchema CustomResourceDefinitionConditionType = "NonStructuralSchema" 301 // Terminating means that the CustomResourceDefinition has been deleted and is cleaning up. 302 Terminating CustomResourceDefinitionConditionType = "Terminating" 303 // KubernetesAPIApprovalPolicyConformant indicates that an API in *.k8s.io or *.kubernetes.io is or is not approved. For CRDs 304 // outside those groups, this condition will not be set. For CRDs inside those groups, the condition will 305 // be true if .metadata.annotations["api-approved.kubernetes.io"] is set to a URL, otherwise it will be false. 306 // See https://github.com/kubernetes/enhancements/pull/1111 for more details. 307 KubernetesAPIApprovalPolicyConformant CustomResourceDefinitionConditionType = "KubernetesAPIApprovalPolicyConformant" 308) 309 310// CustomResourceDefinitionCondition contains details for the current condition of this pod. 311type CustomResourceDefinitionCondition struct { 312 // type is the type of the condition. Types include Established, NamesAccepted and Terminating. 313 Type CustomResourceDefinitionConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=CustomResourceDefinitionConditionType"` 314 // status is the status of the condition. 315 // Can be True, False, Unknown. 316 Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"` 317 // lastTransitionTime last time the condition transitioned from one status to another. 318 // +optional 319 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"` 320 // reason is a unique, one-word, CamelCase reason for the condition's last transition. 321 // +optional 322 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` 323 // message is a human-readable message indicating details about last transition. 324 // +optional 325 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` 326} 327 328// CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition 329type CustomResourceDefinitionStatus struct { 330 // conditions indicate state for particular aspects of a CustomResourceDefinition 331 // +optional 332 // +listType=map 333 // +listMapKey=type 334 Conditions []CustomResourceDefinitionCondition `json:"conditions" protobuf:"bytes,1,opt,name=conditions"` 335 336 // acceptedNames are the names that are actually being used to serve discovery. 337 // They may be different than the names in spec. 338 // +optional 339 AcceptedNames CustomResourceDefinitionNames `json:"acceptedNames" protobuf:"bytes,2,opt,name=acceptedNames"` 340 341 // storedVersions lists all versions of CustomResources that were ever persisted. Tracking these 342 // versions allows a migration path for stored versions in etcd. The field is mutable 343 // so a migration controller can finish a migration to another version (ensuring 344 // no old objects are left in storage), and then remove the rest of the 345 // versions from this list. 346 // Versions may not be removed from `spec.versions` while they exist in this list. 347 // +optional 348 StoredVersions []string `json:"storedVersions" protobuf:"bytes,3,rep,name=storedVersions"` 349} 350 351// CustomResourceCleanupFinalizer is the name of the finalizer which will delete instances of 352// a CustomResourceDefinition 353const CustomResourceCleanupFinalizer = "customresourcecleanup.apiextensions.k8s.io" 354 355// +genclient 356// +genclient:nonNamespaced 357// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 358 359// CustomResourceDefinition represents a resource that should be exposed on the API server. Its name MUST be in the format 360// <.spec.name>.<.spec.group>. 361type CustomResourceDefinition struct { 362 metav1.TypeMeta `json:",inline"` 363 // Standard object's metadata 364 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 365 // +optional 366 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 367 368 // spec describes how the user wants the resources to appear 369 Spec CustomResourceDefinitionSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` 370 // status indicates the actual state of the CustomResourceDefinition 371 // +optional 372 Status CustomResourceDefinitionStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 373} 374 375// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 376 377// CustomResourceDefinitionList is a list of CustomResourceDefinition objects. 378type CustomResourceDefinitionList struct { 379 metav1.TypeMeta `json:",inline"` 380 381 // Standard object's metadata 382 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 383 // +optional 384 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 385 386 // items list individual CustomResourceDefinition objects 387 Items []CustomResourceDefinition `json:"items" protobuf:"bytes,2,rep,name=items"` 388} 389 390// CustomResourceValidation is a list of validation methods for CustomResources. 391type CustomResourceValidation struct { 392 // openAPIV3Schema is the OpenAPI v3 schema to use for validation and pruning. 393 // +optional 394 OpenAPIV3Schema *JSONSchemaProps `json:"openAPIV3Schema,omitempty" protobuf:"bytes,1,opt,name=openAPIV3Schema"` 395} 396 397// CustomResourceSubresources defines the status and scale subresources for CustomResources. 398type CustomResourceSubresources struct { 399 // status indicates the custom resource should serve a `/status` subresource. 400 // When enabled: 401 // 1. requests to the custom resource primary endpoint ignore changes to the `status` stanza of the object. 402 // 2. requests to the custom resource `/status` subresource ignore changes to anything other than the `status` stanza of the object. 403 // +optional 404 Status *CustomResourceSubresourceStatus `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"` 405 // scale indicates the custom resource should serve a `/scale` subresource that returns an `autoscaling/v1` Scale object. 406 // +optional 407 Scale *CustomResourceSubresourceScale `json:"scale,omitempty" protobuf:"bytes,2,opt,name=scale"` 408} 409 410// CustomResourceSubresourceStatus defines how to serve the status subresource for CustomResources. 411// Status is represented by the `.status` JSON path inside of a CustomResource. When set, 412// * exposes a /status subresource for the custom resource 413// * PUT requests to the /status subresource take a custom resource object, and ignore changes to anything except the status stanza 414// * PUT/POST/PATCH requests to the custom resource ignore changes to the status stanza 415type CustomResourceSubresourceStatus struct{} 416 417// CustomResourceSubresourceScale defines how to serve the scale subresource for CustomResources. 418type CustomResourceSubresourceScale struct { 419 // specReplicasPath defines the JSON path inside of a custom resource that corresponds to Scale `spec.replicas`. 420 // Only JSON paths without the array notation are allowed. 421 // Must be a JSON Path under `.spec`. 422 // If there is no value under the given path in the custom resource, the `/scale` subresource will return an error on GET. 423 SpecReplicasPath string `json:"specReplicasPath" protobuf:"bytes,1,name=specReplicasPath"` 424 // statusReplicasPath defines the JSON path inside of a custom resource that corresponds to Scale `status.replicas`. 425 // Only JSON paths without the array notation are allowed. 426 // Must be a JSON Path under `.status`. 427 // If there is no value under the given path in the custom resource, the `status.replicas` value in the `/scale` subresource 428 // will default to 0. 429 StatusReplicasPath string `json:"statusReplicasPath" protobuf:"bytes,2,opt,name=statusReplicasPath"` 430 // labelSelectorPath defines the JSON path inside of a custom resource that corresponds to Scale `status.selector`. 431 // Only JSON paths without the array notation are allowed. 432 // Must be a JSON Path under `.status` or `.spec`. 433 // Must be set to work with HorizontalPodAutoscaler. 434 // The field pointed by this JSON path must be a string field (not a complex selector struct) 435 // which contains a serialized label selector in string form. 436 // More info: https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions#scale-subresource 437 // If there is no value under the given path in the custom resource, the `status.selector` value in the `/scale` 438 // subresource will default to the empty string. 439 // +optional 440 LabelSelectorPath *string `json:"labelSelectorPath,omitempty" protobuf:"bytes,3,opt,name=labelSelectorPath"` 441} 442 443// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 444 445// ConversionReview describes a conversion request/response. 446type ConversionReview struct { 447 metav1.TypeMeta `json:",inline"` 448 // request describes the attributes for the conversion request. 449 // +optional 450 Request *ConversionRequest `json:"request,omitempty" protobuf:"bytes,1,opt,name=request"` 451 // response describes the attributes for the conversion response. 452 // +optional 453 Response *ConversionResponse `json:"response,omitempty" protobuf:"bytes,2,opt,name=response"` 454} 455 456// ConversionRequest describes the conversion request parameters. 457type ConversionRequest struct { 458 // uid is an identifier for the individual request/response. It allows distinguishing instances of requests which are 459 // otherwise identical (parallel requests, etc). 460 // The UID is meant to track the round trip (request/response) between the Kubernetes API server and the webhook, not the user request. 461 // It is suitable for correlating log entries between the webhook and apiserver, for either auditing or debugging. 462 UID types.UID `json:"uid" protobuf:"bytes,1,name=uid"` 463 // desiredAPIVersion is the version to convert given objects to. e.g. "myapi.example.com/v1" 464 DesiredAPIVersion string `json:"desiredAPIVersion" protobuf:"bytes,2,name=desiredAPIVersion"` 465 // objects is the list of custom resource objects to be converted. 466 Objects []runtime.RawExtension `json:"objects" protobuf:"bytes,3,rep,name=objects"` 467} 468 469// ConversionResponse describes a conversion response. 470type ConversionResponse struct { 471 // uid is an identifier for the individual request/response. 472 // This should be copied over from the corresponding `request.uid`. 473 UID types.UID `json:"uid" protobuf:"bytes,1,name=uid"` 474 // convertedObjects is the list of converted version of `request.objects` if the `result` is successful, otherwise empty. 475 // The webhook is expected to set `apiVersion` of these objects to the `request.desiredAPIVersion`. The list 476 // must also have the same size as the input list with the same objects in the same order (equal kind, metadata.uid, metadata.name and metadata.namespace). 477 // The webhook is allowed to mutate labels and annotations. Any other change to the metadata is silently ignored. 478 ConvertedObjects []runtime.RawExtension `json:"convertedObjects" protobuf:"bytes,2,rep,name=convertedObjects"` 479 // result contains the result of conversion with extra details if the conversion failed. `result.status` determines if 480 // the conversion failed or succeeded. The `result.status` field is required and represents the success or failure of the 481 // conversion. A successful conversion must set `result.status` to `Success`. A failed conversion must set 482 // `result.status` to `Failure` and provide more details in `result.message` and return http status 200. The `result.message` 483 // will be used to construct an error message for the end user. 484 Result metav1.Status `json:"result" protobuf:"bytes,3,name=result"` 485} 486