How to Bootstrap Flux From CI
flux bootstrap installs the Flux controllers and commits them to Git, so Flux thereafter manages its own upgrades through GitOps.
Run flux bootstrap github with a kubeconfig and a GitHub PAT. It creates or updates the cluster path in your repo, installs the controllers, and configures them to sync that path.
Steps
- Provide a kubeconfig and a
GITHUB_TOKENwith repo scope as secrets. - Install the Flux CLI in the job.
- Run
flux bootstrap githubwith the owner, repo, and path. - Flux commits its manifests and starts reconciling.
Workflow
.github/workflows/flux-bootstrap.yml
jobs:
bootstrap:
runs-on: ubuntu-latest
steps:
- uses: fluxcd/flux2/action@main
- run: |
flux bootstrap github \
--owner=my-org \
--repository=deploy-config \
--branch=main \
--path=clusters/prod \
--personal=false
env:
GITHUB_TOKEN: ${{ secrets.FLUX_GITHUB_TOKEN }}
KUBECONFIG: ${{ github.workspace }}/kubeconfigGotchas
- Bootstrap is idempotent; re-running it upgrades Flux to the CLI version in use.
- Use
--personal=falsefor org-owned repos so the deploy key is created correctly.
Related guides
How to Set Up a Flux GitRepository and KustomizationWire Flux to a repo with a GitRepository source and a Kustomization that applies a path on an interval, the t…
How to Automate Image Updates With FluxConfigure Flux image automation with ImageRepository, ImagePolicy, and ImageUpdateAutomation so a new registr…