Update Your Project with (alpha update)

Overview

The kubebuilder alpha update command helps you upgrade your project scaffold to a newer Kubebuilder version or plugin layout automatically.

It uses a 3-way merge strategy to update your project with less manual work. To achieve that, the command creates the following branches:

  • Ancestor branch: clean scaffold using the old version
  • Current branch: your existing project with your custom code
  • Upgrade branch: scaffold generated using the new version

Then, it creates a merge branch that combines everything. You can review and test this branch before applying the changes.

When to Use It?

Use this command when:

  • You want to upgrade your project to a newer Kubebuilder version or plugin layout
  • You prefer to automate the migration instead of updating files manually
  • You want to review scaffold changes in a separate Git branch
  • You want to focus only on fixing merge conflicts instead of re-applying all your code

How It Works

The command performs the following steps:

  1. Downloads the older CLI version (from the PROJECT file or --from-version)
  2. Creates tmp-kb-update-ancestor with a clean scaffold using that version
  3. Creates tmp-kb-update-current and restores your current code on top
  4. Creates tmp-kb-update-upgrade using the latest scaffold
  5. Created tmp-kb-update-merge which is a merge of the above branches using the 3-way merge strategy

You can push the tmp-kb-update-merge branch to your remote repository, review the diff, and test the changes before merging into your main branch.

How to Use It

Run the command from your project directory:

kubebuilder alpha update

If needed, set a specific version or branch:

kubebuilder alpha update \
  --from-version=v4.5.2 \
  --to-version=v4.6.0 \
  --from-branch=main

Flags

FlagDescription
--from-versionRequired for projects initialized with versions earlier than v4.6.0. Kubebuilder version your project was created with. If unset, uses the PROJECT file.
--to-versionVersion to upgrade to. Defaults to the latest version.
--from-branchGit branch that contains your current project code. Defaults to main.
-h, --helpShow help for this command.

Requirements

  • A valid PROJECT file at the root of your project
  • A clean Git working directory (no uncommitted changes)
  • Git must be installed and available

Further Resources