go/v2 plugin cannot scaffold projects in which CRDs and/or Webhooks have a
v1 API version.
go/v2 plugin scaffolds with the
v1beta1 API version which was deprecated in Kubernetes
1.16 and removed in
This plugin was kept to ensure backwards compatibility with projects that were scaffolded with the old
"Kubebuilder 2.x" layout and does not work with the new plugin ecosystem that was introduced with Kubebuilder
28 Apr 2021, the default layout produced by Kubebuilder changed and is done via the
We encourage you migrate your project to the latest version if your project was built with a Kubebuilder
The recommended way to migrate a
v2 project is to create a new
v3 project and copy over the API
and the reconciliation code. The conversion will end up with a project that looks like a native
For further information check the
go/v2 plugin has the purpose to scaffold Golang projects to help users
to build projects with
controllers and keep the backwards compatibility
with the default scaffold made using Kubebuilder CLI
You can check samples using this plugin by looking at the
project-v2-<options> directories under the
testdata projects on the root directory of the Kubebuilder project.
Only if you are looking to scaffold a project with the legacy layout. Otherwise, it is recommended you to use the default Golang version plugin.
Be aware that this plugin version does not provide a scaffold compatible with the latest versions of the dependencies used in order to keep its backwards compatibility.
To initialize a Golang project using the legacy layout and with this plugin run, e.g.:
kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --plugins=go/v2
By creating a project with this plugin, the PROJECT file scaffold will be using the previous schema (
project version 2). So that Kubebuilder CLI knows what plugin version was used and will call its subcommands such as
create api and
create webhooks. Note that further Golang plugins versions use the new Project file schema, which tracks the information about what plugins and versions have been used so far.
kubebuilder init [OPTIONS]
kubebuilder edit [OPTIONS]
Create API -
kubebuilder create api [OPTIONS]
Create Webhook -
kubebuilder create webhook [OPTIONS]