go/v4-alpha (go.kubebuilder.io/v4-alpha)
Kubebuilder will scaffold using the go/v4-alpha
plugin only if specified when initializing the project.
This plugin is a composition of the plugins kustomize.common.kubebuilder.io/v2-alpha
and base.go.kubebuilder.io/v4-alpha
.
It scaffolds a project template that helps in constructing sets of controllers.
It scaffolds boilerplate code to create and design controllers. Note that by following the quickstart you will be using this plugin.
When to use it ?
- If you are looking to scaffold Golang projects to develop projects using controllers
- If you are looking to experiment with the future default scaffold that will be provided by Kubebuilder CLI
- If your local environment is Apple Silicon (
darwin/arm64
) - If you are looking to use kubernetes-sigs/kustomize v4
- If you are looking to have your project update with the latest version available
- if you are not targeting k8s versions <
1.16
and1.20
if you are using webhooks - If you are looking to work on with scaffolds which are compatible with k8s
1.25+
- If you are looking for the new layout following the Standard Go Project Layout where
the “api(s)” are scaffold under the
api
directory, “controller(s)” underinternal
, and themain.go
undercmd
How to use it ?
To create a new project with the go/v4-alpha
plugin the following command can be used:
kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --plugins=go/v4-alpha
Subcommands supported by the plugin
- Init -
kubebuilder init [OPTIONS]
- Edit -
kubebuilder edit [OPTIONS]
- Create API -
kubebuilder create api [OPTIONS]
- Create Webhook -
kubebuilder create webhook [OPTIONS]
Further resources
- To see the composition of plugins, you can check the source code for the Kubebuilder main.go.
- Check the code implementation of the [base Golang plugin
base.go.kubebuilder.io/v3
][v3-plugin]. - Check the code implementation of the Kustomize/v2-alpha plugin.
- Check controller-runtime to know more about controllers.