api

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 74 Imported by: 0

README

api

The canonical location of the OpenShift API definition. This repo holds the API type definitions and serialization code used by openshift/client-go

defining new APIs

When defining a new API, please follow the OpenShift API conventions, and then follow the instructions below to regenerate CRDs (if necessary) and submit a pull request with your new API definitions and generated files.

generating CRD schemas

Since Kubernetes 1.16, every CRD created in apiextensions.k8s.io/v1 is required to have a structural OpenAPIV3 schema. The schemas provide server-side validation for fields, as well as providing the descriptions for oc explain. Moreover, schemas ensure structural consistency of data in etcd. Without it anything can be stored in a resource which can have security implications. As we host many of our CRDs in this repo along with their corresponding Go types we also require them to have schemas. However, the following instructions apply for CRDs that are not hosted here as well.

These schemas are often very long and complex, and should not be written by hand. For OpenShift, we provide Makefile targets in build-machinery-go which generate the schema, built on upstream's controller-gen tool.

If you make a change to a CRD type in this repo, simply calling make update-codegen-crds should regenerate all CRDs and update the manifests. If yours is not updated, ensure that the path to its API is included in our calls to the Makefile targets.

To add this generator to another repo:

  1. Vendor github.com/openshift/build-machinery-go

  2. Update your Makefile to include the following:

include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
  targets/openshift/crd-schema-gen.mk \
)

$(call add-crd-gen,<TARGET_NAME>,<API_DIRECTORY>,<CRD_MANIFESTS>,<MANIFEST_OUTPUT>)

The parameters for the call are:

  1. TARGET_NAME: The name of your generated Make target. This can be anything, as long as it does not conflict with another make target. Recommended to be your api name.
  2. API_DIRECTORY: The location of your API. For example if your Go types are located under pkg/apis/myoperator/v1/types.go, this should be ./pkg/apis/myoperator/v1.
  3. CRD_MANIFESTS: The directory your CRDs are located in. For example, if that is manifests/my_operator.crd.yaml then it should be ./manifests
  4. MANIFEST_OUTPUT: This should most likely be the same as CRD_MANIFESTS, and is only provided for flexibility to output generated code to a different directory.

You can include as many calls to different APIs as necessary, or if you have multiple APIs under the same directory (eg, v1 and v2beta1) you can use 1 call to the parent directory pointing to your API.

After this, calling make update-codegen-crds should generate a new structural OpenAPIV3 schema for your CRDs.

Notes

  • This will not generate entire CRDs, only their OpenAPIV3 schemas. If you do not already have a CRD, you will get no output from the generator.
  • Ensure that your API is correctly declared for the generator to pick it up. That means, in your doc.go, include the following:
    1. // +groupName=<API_GROUP_NAME>, this should match the group in your CRD spec
    2. // +kubebuilder:validation:Optional, this tells the operator that fields should be optional unless explicitly marked with // +kubebuilder:validation:Required

For more information on the API markers to add to your Go types, see the Kubebuilder book

Post-schema-generation Patches

Schema generation features might be limited or fall behind what CRD schemas supports in the latest Kubernetes version. To work around this, there are two patch mechanisms implemented by the add-crd-gen target. Basic idea is that you place a patch file next to the CRD yaml manifest with either yaml-merge-patch or yaml-patch as extension, but with the same base name. The update-codegen-crds Makefile target will apply these after calling kubebuilder's controller-gen:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Install is a function which adds every version of every openshift group to a scheme
	Install = schemeBuilder.AddToScheme

	// InstallKube is a way to install all the external k8s.io/api types
	InstallKube = kubeSchemeBuilder.AddToScheme
)

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
v1
+kubebuilder:validation:Optional +groupName=apiserver.openshift.io Package v1 is the v1 version of the API.
+kubebuilder:validation:Optional +groupName=apiserver.openshift.io Package v1 is the v1 version of the API.
v1
+groupName=apps.openshift.io Package v1 is the v1 version of the API.
+groupName=apps.openshift.io Package v1 is the v1 version of the API.
v1
+kubebuilder:validation:Optional +groupName=authorization.openshift.io Package v1 is the v1 version of the API.
+kubebuilder:validation:Optional +groupName=authorization.openshift.io Package v1 is the v1 version of the API.
v1
+groupName=build.openshift.io Package v1 is the v1 version of the API.
+groupName=build.openshift.io Package v1 is the v1 version of the API.
v1
Package v1 contains API Schema definitions for the cloud network v1 API group +k8s:deepcopy-gen=package,register +groupName=cloud.network.openshift.io +kubebuilder:validation:Optional
Package v1 contains API Schema definitions for the cloud network v1 API group +k8s:deepcopy-gen=package,register +groupName=cloud.network.openshift.io +kubebuilder:validation:Optional
cmd
v1
+kubebuilder:validation:Optional +groupName=config.openshift.io Package v1 is the v1 version of the API.
+kubebuilder:validation:Optional +groupName=config.openshift.io Package v1 is the v1 version of the API.
v1
+groupName=console.openshift.io Package v1 is the v1 version of the API.
+groupName=console.openshift.io Package v1 is the v1 version of the API.
v1alpha1
+groupName=console.openshift.io
+groupName=console.openshift.io
hack
v1beta1
+kubebuilder:validation:Optional +groupName=helm.openshift.io Package v1 is the v1 version of the API.
+kubebuilder:validation:Optional +groupName=helm.openshift.io Package v1 is the v1 version of the API.
docker10
Package docker10 is the docker10 version of the API.
Package docker10 is the docker10 version of the API.
dockerpre012
Package dockerpre012 is the dockerpre012 version of the API.
Package dockerpre012 is the dockerpre012 version of the API.
v1
+groupName=image.openshift.io Package v1 is the v1 version of the API.
+groupName=image.openshift.io Package v1 is the v1 version of the API.
v1
+k8s:deepcopy-gen=package +groupName=imageregistry.operator.openshift.io
+k8s:deepcopy-gen=package +groupName=imageregistry.operator.openshift.io
v1
+groupName=kubecontrolplane.config.openshift.io Package v1 is the v1 version of the API.
+groupName=kubecontrolplane.config.openshift.io Package v1 is the v1 version of the API.
legacyconfig
v1
+groupName=legacy.config.openshift.io Package v1 is deprecated and exists to ease a transition to current APIs
+groupName=legacy.config.openshift.io Package v1 is deprecated and exists to ease a transition to current APIs
v1
+kubebuilder:validation:Optional +groupName=machine.openshift.io
+kubebuilder:validation:Optional +groupName=machine.openshift.io
v1beta1
+kubebuilder:validation:Optional +groupName=machine.openshift.io
+kubebuilder:validation:Optional +groupName=machine.openshift.io
v1
+groupName=network.openshift.io Package v1 is the v1 version of the API.
+groupName=network.openshift.io Package v1 is the v1 version of the API.
v1
Package v1 contains API Schema definitions for the network v1 API group +k8s:deepcopy-gen=package,register +groupName=network.operator.openshift.io +kubebuilder:validation:Optional
Package v1 contains API Schema definitions for the network v1 API group +k8s:deepcopy-gen=package,register +groupName=network.operator.openshift.io +kubebuilder:validation:Optional
v1
+groupName=oauth.openshift.io Package v1 is the v1 version of the API.
+groupName=oauth.openshift.io Package v1 is the v1 version of the API.
v1
+groupName=openshiftcontrolplane.config.openshift.io Package v1 is the v1 version of the API.
+groupName=openshiftcontrolplane.config.openshift.io Package v1 is the v1 version of the API.
v1
+kubebuilder:validation:Optional +groupName=operator.openshift.io
+kubebuilder:validation:Optional +groupName=operator.openshift.io
v1alpha1
+groupName=operator.openshift.io
+groupName=operator.openshift.io
v1alpha1
Package v1alpha1 is an API version in the controlplane.operator.openshift.io group
Package v1alpha1 is an API version in the controlplane.operator.openshift.io group
v1
+kubebuilder:validation:Optional +groupName=ingress.operator.openshift.io
+kubebuilder:validation:Optional +groupName=ingress.operator.openshift.io
v1
+groupName=osin.config.openshift.io Package v1 is the v1 version of the API.
+groupName=osin.config.openshift.io Package v1 is the v1 version of the API.
pkg
v1
+groupName=project.openshift.io Package v1 is the v1 version of the API.
+groupName=project.openshift.io Package v1 is the v1 version of the API.
v1
+groupName=quota.openshift.io Package v1 is the v1 version of the API.
+groupName=quota.openshift.io Package v1 is the v1 version of the API.
v1
+groupName=route.openshift.io Package v1 is the v1 version of the API.
+groupName=route.openshift.io Package v1 is the v1 version of the API.
v1
+groupName=samples.operator.openshift.io Package v1 ist he v1 version of the API.
+groupName=samples.operator.openshift.io Package v1 ist he v1 version of the API.
v1
+groupName=security.openshift.io Package v1 is the v1 version of the API.
+groupName=security.openshift.io Package v1 is the v1 version of the API.
v1
+kubebuilder:validation:Optional +groupName=security.internal.openshift.io Package v1 is the v1 version of the API.
+kubebuilder:validation:Optional +groupName=security.internal.openshift.io Package v1 is the v1 version of the API.
v1alpha1
+groupName=servicecertsigner.config.openshift.io
+groupName=servicecertsigner.config.openshift.io
v1alpha1
+groupName=sharedresource.openshift.io Package v1alplha1 is the v1alpha1 version of the API.
+groupName=sharedresource.openshift.io Package v1alplha1 is the v1alpha1 version of the API.
v1
+groupName=template.openshift.io Package v1 is the v1 version of the API.
+groupName=template.openshift.io Package v1 is the v1 version of the API.
tools
genswaggertypedocs
lifted from k8s.io/kubernetes so we can add methods to types
lifted from k8s.io/kubernetes so we can add methods to types
unidling
v1
+groupName=user.openshift.io Package v1 is the v1 version of the API.
+groupName=user.openshift.io Package v1 is the v1 version of the API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL