docs/book/src/migrations.md
Upgrading your Kubebuilder project to the latest version ensures you benefit from new features, bug fixes, and ecosystem improvements. It is recommended to keep your project aligned with ecosystem changes.
Migration may involve updating to a newer plugin version (e.g., from go.kubebuilder.io/v3 in release 3.x to go.kubebuilder.io/v4 in release 4.x) or updating the scaffold produced by the same plugin across CLI releases (e.g., from v4.9.0 to v4.10.1).
Kubebuilder provides multiple migration paths to suit your workflow. Choose the approach that best fits your needs.
<aside class="note"> <h1>Understanding the PROJECT File</h1>From Kubebuilder v3.0.0 onwards, all inputs used by Kubebuilder are tracked in the PROJECT file.
If you use the CLI to generate your scaffolds, this file will record the project's configuration and metadata,
enabling all automation tools to work effectively.
It is recommended to use the CLI to scaffold all resources (kubebuilder create api, kubebuilder create webhook, etc.)
whenever possible, including controllers and webhooks for external types. The CLI has been continuously improved
over time to address various options and needs. This ensures all resources are tracked in the PROJECT file,
which automation tools (alpha update, alpha generate, autoupdate plugin) depend on.
After using the CLI to create your project, you are free to customize the business logic and add features as you see fit. However, it is not recommended to deviate from the proposed project layout unless you know what you are doing.
For example, you should refrain from moving the scaffolded files, as doing so may will make it difficult to upgrade your project in the future. You may also lose the ability to use some of the CLI features and helpers.
Projects that do not use the CLI to generate scaffolds, or that deviate heavily from the proposed layout, may need to use the manual migration process, as automated migration tools might not work properly while the alpha update and AutoUpdate Plugin are designed to do a 3-way merge to keep your customizations intact.
For further information on the project layout, see What's in a basic project?
</aside>[!TIP] To reduce effort, we recommend enabling the AutoUpdate Plugin (GitHub Actions). You can also run alpha update locally—both use the same update logic. Use the other options mainly for older projects that do not have
cliVersionin thePROJECTfile as a one-time step to reach a supported version; after that, use these workflows for future updates (older versions cannot use these automation features).
The AutoUpdate Plugin scaffolds an action that automatically monitors for new Kubebuilder releases and opens a GitHub Issue with a Pull Request compare link when updates are available. This is ideal for keeping your project up to date with minimal manual work.
This plugin provides a mechanism similar to Dependabot for GitHub, offering continuous updates with AI assistance for projects that follow the standard scaffold.
kubebuilder edit --plugins="autoupdate/v1-alpha"
alpha update (see below)See the AutoUpdate Plugin documentation for complete details.
alpha update to Upgrade Without Losing Customisations (Logic Behind AutoUpdate/GitHub Action)If you prefer to run updates locally instead of relying on GitHub Actions, you can use the same logic as the AutoUpdate Plugin directly from your command line.
kubebuilder alpha update
This command uses the same underlying mechanism as the AutoUpdate Plugin. You can migrate your project, resolve any conflicts if needed, and then push a Pull Request from your local environment.
<aside class="note"> <h1>Requirements and Limitations</h1>v4.5.0 or laterv4.6.0: the CLI version is not tracked in the PROJECT file, so you may need to use alpha generate first to establish a baselinev4.6.0+: includes cliVersion in the PROJECT file for automatic version detectionSee the alpha update command reference for all options and flags.
The kubebuilder alpha generate command re-scaffolds your entire project based on your PROJECT file
configuration. You can then manually compare and merge your custom code. For example, you can use it to
regenerate your project after upgrading the Kubebuilder CLI version and then, manually use an IDE or
git diff to compare and merge changes by hand into your existing codebase to ensure that all your changes
are applied in a new scaffold.
This approach is useful for projects that heavily customize the scaffold or when other migration methods aren't available. You might need to use this method only once to establish a baseline for future automated updates.
kubebuilder alpha generate
PROJECT file (projects created with Kubebuilder v3.0.0 or later)PROJECT fileSee the alpha generate command reference for details.
For complete control, you can manually migrate by creating a new project with the latest Kubebuilder version and porting your code over.
In this process, you will run all commands from scratch to create a new project, APIs, controllers, webhooks, and other resources. Then, manually copy your business logic and customizations from your old project to the new one.
To streamline this one-time migration, AI Migration Helpers have been added to automate repetitive tasks.
<aside class="note"> <h1>When to Use Manual Migration</h1>Use this approach when:
v3.0.0 (no PROJECT file)See the Manual Migration Process Guide for a complete step-by-step walkthrough with AI helpers.