Changing branch used by Flux deployment
If the need arises to change the branch used by a Flux installation, this can be done without bootstrapping the cluster again. Not that this is recommended only on similar setups (e.g. you’re trying out a new change on a dev cluster and want to point to your dev branch which is based on the default branch).
Components
This article assumes the following components are in play:
- Kubernetes cluster called
cluster01 - Flux mono repo with the cluster definition in the locations
clusters/development(this folder contains theflux-systemfolder) - A default branch called
main - A working branch called
12345-something-to-testthat is based onmainwith a new change in it
Process
- Switch to your working branch
- Run the following command at a shell prompt (Bash, PowerShell, etc…) when the current context is you the target cluster:
flux suspend source git flux-system - Update
clusters/development/flux-system/gotk-sync.yamlto set the value of branch to12345-something-to-testand commit and push it - Within your Kubernetes cluster, update the resource of type
GitRepositorynamedflux-systemin theflux-systemnamespace so the branch field is also12345-something-to-test - Run the following command at a shell prompt (Bash, PowerShell, etc…) when the current context is you the target cluster:
flux resume source git flux-system
Once testing is complete, repeat the above process but setting the branch back to main.