...

Source file src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go

Documentation: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1

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

View as plain text