CRD Generation
These markers describe how to construct a custom resource definition from a series of Go types and packages. Generation of the actual validation schema is described by the validation markers.
See Generating CRDs for examples.
- // +groupName
 - string
 
specifies the API group name for this package.
- string
 
- // +kubebuilder:deprecatedversion
 - warning
 - string
 
marks this version as deprecated.
- warning
 - string
 message to be shown on the deprecated version
- // +kubebuilder:metadata
 - annotations
 - string
 - labels
 - string
 
configures the additional annotations or labels for this CRD.
For example adding annotation "api-approved.kubernetes.io" for a CRD with Kubernetes groups, or annotation "cert-manager.io/inject-ca-from-secret" for a CRD that needs CA injection.
- annotations
 - string
 will be added into the annotations of this CRD.
- labels
 - string
 will be added into the labels of this CRD.
- // +kubebuilder:printcolumn
 - JSONPath
 - string
 - description
 - string
 - format
 - string
 - name
 - string
 - priority
 - int
 - type
 - string
 
adds a column to "kubectl get" output for this CRD.
- JSONPath
 - string
 specifies the jsonpath expression used to extract the value of the column.
- description
 - string
 specifies the help/description for this column.
- format
 - string
 specifies the format of the column.
It may be any OpenAPI data format corresponding to the type, listed at https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types.
- name
 - string
 specifies the name of the column.
- priority
 - int
 indicates how important it is that this column be displayed.
Lower priority (higher numbered) columns will be hidden if the terminal width is too small.
- type
 - string
 indicates the type of the column.
It may be any OpenAPI data type listed at https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types.
- // +kubebuilder:resource
 - categories
 - string
 - path
 - string
 - scope
 - string
 - shortName
 - string
 - singular
 - string
 
configures naming and scope for a CRD.
- categories
 - string
 specifies which group aliases this resource is part of.
Group aliases are used to work with groups of resources at once. The most common one is "all" which covers about a third of the base resources in Kubernetes, and is generally used for "user-facing" resources.
- path
 - string
 specifies the plural "resource" for this CRD.
It generally corresponds to a plural, lower-cased version of the Kind. See https://book.kubebuilder.io/cronjob-tutorial/gvks.html.
- scope
 - string
 overrides the scope of the CRD (Cluster vs Namespaced).
Scope defaults to "Namespaced". Cluster-scoped ("Cluster") resources don't exist in namespaces.
- shortName
 - string
 specifies aliases for this CRD.
Short names are often used when people have work with your resource over and over again. For instance, "rs" for "replicaset" or "crd" for customresourcedefinition.
- singular
 - string
 overrides the singular form of your resource.
The singular form is otherwise defaulted off the plural (path).
- // +kubebuilder:selectablefield
 - JSONPath
 - string
 
adds a field that may be used with field selectors.
- JSONPath
 - string
 specifies the jsonpath expression which is used to produce a field selector value.
- // +kubebuilder:skip
 don't consider this package as an API version.
- // +kubebuilder:skipversion
 removes the particular version of the CRD from the CRDs spec.
This is useful if you need to skip generating and listing version entries for 'internal' resource versions, which typically exist if using the Kubernetes upstream conversion-gen tool.
- // +kubebuilder:storageversion
 marks this version as the "storage version" for the CRD for conversion.
When conversion is enabled for a CRD (i.e. it's not a trivial-versions/single-version CRD), one version is set as the "storage version" to be stored in etcd. Attempting to store any other version will result in conversion to the storage version via a conversion webhook.
- // +kubebuilder:subresource:scale
 - selectorpath
 - string
 - specpath
 - string
 - statuspath
 - string
 
enables the "/scale" subresource on a CRD.
- selectorpath
 - string
 specifies the jsonpath to the pod label selector field for the scale's status.
The selector field must be the string form (serialized form) of a selector. Setting a pod label selector is necessary for your type to work with the HorizontalPodAutoscaler.
- specpath
 - string
 specifies the jsonpath to the replicas field for the scale's spec.
- statuspath
 - string
 specifies the jsonpath to the replicas field for the scale's status.
- // +kubebuilder:subresource:status
 enables the "/status" subresource on a CRD.
- // +kubebuilder:unservedversion
 does not serve this version.
This is useful if you need to drop support for a version in favor of a newer version.
- // +versionName
 - string
 
overrides the API group version for this package (defaults to the package name).
- string
 
