GitOps with Flux CD
Flux CD is a GitOps operator for Kubernetes. It watches a Git repository and automatically applies changes to the cluster when manifests are updated. This enables a pull-based deployment model where Git is the single source of truth.
What this page covers
- GitOps concepts: why Git as the source of truth
- Installing the Flux CLI
- Bootstrapping Flux to a Gitea repository
- Repository structure:
clusters/,apps/,infrastructure/ - How Flux reconciles changes
- Image automation: automatically updating image tags on new pushes
Why GitOps
In a traditional push-based deployment, CI/CD pipelines kubectl apply directly to the cluster. In a pull-based GitOps model:
- A developer merges a change to Git.
- Flux detects the change and pulls it into the cluster.
- The cluster state always matches Git.
This means rollbacks are as simple as a git revert.
Bootstrapping Flux
flux bootstrap gitea \
--owner=your-org \
--repository=fleet-infra \
--branch=main \
--path=clusters/my-cluster \
--personal