Flux CD is the CNCF graduated GitOps toolkit for Kubernetes. It automatically syncs your cluster state with Git repositories — any change in Git is applied to your cluster within seconds.
Free, open source, used by companies like Deutsche Telekom, SAP, and D2iQ.
Why Use Flux?
- True GitOps — Git is the single source of truth for your cluster
- Multi-tenancy — multiple teams, multiple repos, one cluster
- Helm & Kustomize — native support for both
- Image automation — auto-update deployments when new images are pushed
- Notifications — Slack, Teams, Discord alerts on deploy events
Quick Setup
1. Install Flux
# Bootstrap with GitHub
flux bootstrap github \
--owner=my-org \
--repository=fleet-infra \
--branch=main \
--path=clusters/production
# Check status
flux check
2. Add a Git Source
flux create source git my-app \
--url=https://github.com/my-org/my-app \
--branch=main \
--interval=1m
# Check via kubectl
kubectl get gitrepositories -A
kubectl get gitrepositories my-app -o json | jq '{url: .spec.url, ready: .status.conditions[-1].status, revision: .status.artifact.revision}'
3. Create a Kustomization
flux create kustomization my-app \
--source=GitRepository/my-app \
--path=./deploy \
--prune=true \
--interval=5m
# Check status
kubectl get kustomizations -A
4. Add Helm Release
# Add Helm repository
flux create source helm bitnami \
--url=https://charts.bitnami.com/bitnami \
--interval=1h
# Install chart
flux create helmrelease nginx \
--source=HelmRepository/bitnami \
--chart=nginx \
--values=./values.yaml
# Check releases
kubectl get helmreleases -A -o json | jq '.items[] | {name: .metadata.name, status: .status.conditions[-1].reason, revision: .status.lastAppliedRevision}'
5. Image Automation
# Watch for new images
flux create image repository my-app \
--image=ghcr.io/my-org/my-app \
--interval=5m
# Auto-update policy
flux create image policy my-app \
--image-ref=my-app \
--select-semver='>=1.0.0'
# Check latest image
kubectl get imagerepositories
kubectl get imagepolicies -o json | jq '.items[] | {name: .metadata.name, latest: .status.latestImage}'
Python Example
from kubernetes import client, config
config.load_kube_config()
api = client.CustomObjectsApi()
# List all Flux Kustomizations
kusts = api.list_cluster_custom_object(
group="kustomize.toolkit.fluxcd.io", version="v1", plural="kustomizations")
for k in kusts["items"]:
name = k["metadata"]["name"]
ready = any(c["type"]=="Ready" and c["status"]=="True" for c in k.get("status",{}).get("conditions",[]))
revision = k.get("status",{}).get("lastAppliedRevision","N/A")[:12]
print(f"Kustomization: {name} | Ready: {ready} | Revision: {revision}")
# List Helm Releases
helms = api.list_cluster_custom_object(
group="helm.toolkit.fluxcd.io", version="v2", plural="helmreleases")
for h in helms["items"]:
print(f"HelmRelease: {h['metadata']['name']} | Chart: {h['spec']['chart']['spec']['chart']} | Version: {h.get('status',{}).get('lastAppliedRevision','pending')}")
Key Resources
| Resource | Group | Description |
|---|---|---|
| GitRepository | source.toolkit.fluxcd.io | Git source |
| HelmRepository | source.toolkit.fluxcd.io | Helm chart source |
| Kustomization | kustomize.toolkit.fluxcd.io | Kustomize deployment |
| HelmRelease | helm.toolkit.fluxcd.io | Helm chart deployment |
| ImageRepository | image.toolkit.fluxcd.io | Image tracking |
| ImagePolicy | image.toolkit.fluxcd.io | Image update policy |
Need custom data extraction or scraping solution? I build production-grade scrapers for any website. Email: Spinov001@gmail.com | My Apify Actors
Top comments (0)