What is Flux CD? GitOps with Kubernetes-native controllers
Explore Flux's architecture, its main CRDs with real examples, how to bootstrap a cluster, decrypt secrets with SOPS, isolate teams, and when to choose Flux over Argo CD.
Kubernetes$ flux check --pre▍Flux is a GitOps toolkit for Kubernetes and a graduated CNCF project. Unlike Argo CD, it has no central server and no built-in web UI: it’s a group of Kubernetes controllers, and everything — including Flux’s own configuration — is a Kubernetes resource versioned in Git. If the concept is still new to you, read What is GitOps? first.
Architecture: a set of controllers
Each controller has one responsibility and talks to the others through Kubernetes resources:
| Controller | Responsibility | Main CRDs |
|---|---|---|
| source-controller | Fetches artifacts from sources (Git, Helm repositories, OCI, buckets) | GitRepository, HelmRepository, OCIRepository, Bucket |
| kustomize-controller | Applies manifests (via Kustomize) with pruning and health checks | Kustomization |
| helm-controller | Installs, upgrades, and rolls back Helm releases | HelmRelease |
| notification-controller | Sends alerts (Slack, Teams, webhooks) and receives Git webhooks | Provider, Alert, Receiver |
| image-reflector-controller | Reads the tags available in image registries | ImageRepository, ImagePolicy |
| image-automation-controller | Updates manifests in Git with the new tag | ImageUpdateAutomation |
The two image controllers are optional and must be enabled at bootstrap.
The CRDs in practice
GitRepository and Kustomization
The source, and what to do with it:
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: k8s-manifests
namespace: flux-system
spec:
interval: 1m
url: https://github.com/your-org/k8s-manifests
ref:
branch: main
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: apps
namespace: flux-system
spec:
interval: 10m
path: ./apps/prod
prune: true
wait: true
sourceRef:
kind: GitRepository
name: k8s-manifests
Mind the name: Flux’s Kustomization is a CRD, distinct from Kustomize’s kustomization.yaml file — although it uses Kustomize under the hood. With wait: true, Flux only considers a reconciliation complete once the applied resources become healthy. For private repositories, add spec.secretRef to the GitRepository.
HelmRepository and HelmRelease
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: podinfo
namespace: flux-system
spec:
interval: 1h
url: https://stefanprodan.github.io/podinfo
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: podinfo
spec:
interval: 10m
chart:
spec:
chart: podinfo
version: "6.x"
sourceRef:
kind: HelmRepository
name: podinfo
namespace: flux-system
values:
replicaCount: 2
The helm-controller uses the Helm SDK: the result is a real Helm release that shows up in helm list, with history, chart hooks, and automatic remediation options on failure. If you’re not comfortable with charts yet, see What is Helm?.
Image automation
Flux can detect a new tag in the registry and commit the update to Git, without relying on CI:
# image.toolkit.fluxcd.io/v1 in current Flux versions; older versions used v1beta2.
# Check your cluster: kubectl api-resources | grep image.toolkit
apiVersion: image.toolkit.fluxcd.io/v1
kind: ImageRepository
metadata:
name: api
namespace: flux-system
spec:
image: ghcr.io/your-org/api
interval: 5m
---
apiVersion: image.toolkit.fluxcd.io/v1
kind: ImagePolicy
metadata:
name: api
namespace: flux-system
spec:
imageRepositoryRef:
name: api
policy:
semver:
range: ">=1.0.0"
---
apiVersion: image.toolkit.fluxcd.io/v1
kind: ImageUpdateAutomation
metadata:
name: k8s-manifests
namespace: flux-system
spec:
interval: 30m
sourceRef:
kind: GitRepository
name: k8s-manifests
git:
commit:
author:
name: fluxcdbot
email: [email protected]
messageTemplate: "chore: update images"
push:
branch: main
update:
path: ./apps
strategy: Setters
In the manifest, a comment marks which field to update: image: ghcr.io/your-org/api:1.3.2 # {"$imagepolicy": "flux-system:api"}. For production, prefer pushing to a separate branch and opening a Pull Request instead of committing straight to main.
Bootstrapping a cluster
flux bootstrap installs the controllers, commits Flux’s own manifests to the repository, and creates the GitRepository and Kustomization pointing to the cluster’s path. From then on, Flux manages itself:
export GITHUB_TOKEN=<token-with-repo-access>
flux check --pre
# --personal: the owner is a user, not an organization
flux bootstrap github \
--owner=your-user \
--repository=fleet-infra \
--branch=main \
--path=clusters/prod \
--personal \
--components-extra=image-reflector-controller,image-automation-controller
flux get kustomizations
flux get helmreleases -A
flux reconcile kustomization flux-system --with-source
flux logs --level=error
To upgrade Flux, just run bootstrap again with the new CLI version.
Secrets with SOPS
The kustomize-controller natively decrypts files encrypted with SOPS (using age, OpenPGP, or cloud KMS such as AWS KMS, GCP KMS, and Azure Key Vault). You commit the encrypted secret and point the Kustomization at the key:
spec:
decryption:
provider: sops
secretRef:
name: sops-age
The private key lives only in the cluster, in a secret created with kubectl create secret generic sops-age -n flux-system --from-file=age.agekey=age.agekey. Never commit it.
Multi-tenancy
Flux relies on Kubernetes’ own RBAC to isolate teams:
- Each team gets its own namespace and its own
GitRepository/Kustomization. - The
spec.serviceAccountNamefield makes the controller impersonate a tenant service account, limited to that account’s permissions. - On shared clusters, enable lockdown: the
--no-cross-namespace-refs=trueand--default-service-accountcontroller flags block cross-namespace references and prevent applying with admin permissions by default. - The
flux create tenantcommand generates a team’s namespace, service account, and RoleBinding.
A bit of history
Flux was created by Weaveworks, the same company that popularized the term GitOps. Version 2 was rewritten as the GitOps Toolkit, the controller architecture described above. In 2024, Weaveworks shut down; the project continues under CNCF governance, with maintainers from other companies and the community. For the current state of the project and its roadmap, check the official website.
Flux or Argo CD?
| Criterion | Prefer Flux | Prefer Argo CD |
|---|---|---|
| Interface | The team is comfortable with CLI and CRDs | Developers want a web UI with state and diffs |
| Helm | Native Helm releases (helm list, Helm rollback) |
Rendering charts as manifests is enough |
| Topology | One autonomous agent per cluster | One central dashboard managing many clusters |
| Image automation | Native, with commits to Git | Via Argo CD Image Updater |
| Multi-tenancy | Kubernetes RBAC and impersonation | AppProjects and Argo CD’s own RBAC |
| Components | Controllers only | API server, UI, Redis, and optionally Dex |
To see how both fit into a complete delivery flow, read Pure GitOps: separating CI from CD.
Checklist
-
flux check --prepasses before bootstrap - Bootstrap with one
--pathper cluster and Flux itself versioned in Git -
prune: trueandwait(orhealthChecks) on Kustomizations - HelmReleases with a controlled chart version or semver range
- Secrets encrypted with SOPS and the private key kept out of Git
- Tenants with
serviceAccountNameand cross-namespace references blocked - notification-controller alerts reaching the team’s channel
With Flux, there’s no dashboard to click: the cluster is the dashboard, and Git is the only deploy button.