Kubebuilder v1 vs v2 (Legacy v1.0.0+ to v2.0.0 Kubebuilder CLI versions)
This document cover all breaking changes when migrating from v1 to v2.
The details of all changes (breaking or otherwise) can be found in controller-runtime, controller-tools and kubebuilder release notes.
Common changes
V2 project uses go modules. But kubebuilder will continue to support dep until
go 1.13 is out.
controller-runtime
-
Client.Listnow uses functional options (List(ctx, list, ...option)) instead ofList(ctx, ListOptions, list). -
Client.DeleteAllOfwas added to theClientinterface. -
Metrics are on by default now.
-
A number of packages under
pkg/runtimehave been moved, with their old locations deprecated. The old locations will be removed before controller-runtime v1.0.0. See the godocs for more information.
Webhook-related
-
Automatic certificate generation for webhooks has been removed, and webhooks will no longer self-register. Use controller-tools to generate a webhook configuration. If you need certificate generation, we recommend using cert-manager. Kubebuilder v2 will scaffold out cert manager configs for you to use – see the Webhook Tutorial for more details.
-
The
builderpackage now has separate builders for controllers and webhooks, which facilitates choosing which to run.
controller-tools
The generator framework has been rewritten in v2. It still works the same as before in many cases, but be aware that there are some breaking changes. Please check marker documentation for more details.
Kubebuilder
-
Kubebuilder v2 introduces a simplified project layout. You can find the design doc here.
-
In v1, the manager is deployed as a
StatefulSet, while it’s deployed as aDeploymentin v2. -
The
kubebuilder create webhookcommand was added to scaffold mutating/validating/conversion webhooks. It replaces thekubebuilder alpha webhookcommand. -
v2 uses
distroless/staticinstead of Ubuntu as base image. This reduces image size and attack surface. -
v2 requires kustomize v3.1.0+.
