Manage Flux with the Flux CLI
Check, inspect, reconcile, diff, trace, suspend, and troubleshoot Flux resources from the terminal.
Flux has no built-in web UI. Everything you do day to day goes through the flux CLI and kubectl, which also makes it easy to script. This guide assumes Flux is bootstrapped and the webapp Kustomization from the earlier guides exists.
Install the CLI and check the cluster
Install the CLI (brew install fluxcd/tap/flux on macOS, or curl -s https://fluxcd.io/install.sh | sudo bash) and check it:
flux --version
flux check --pre # before installing: is the cluster compatible?
flux check # after installing: are the controllers healthy?
Run flux --help to list commands. Most commands read from the flux-system namespace by default. Add -A (--all-namespaces) to look everywhere, or -n <namespace> for a specific one.
Inspect what exists
flux get all -A
flux get sources git
flux get kustomizations
flux get helmreleases -A
Each row shows the object’s revision, whether it is Ready, whether it is suspended, and the latest status message. flux get all -A is a good first command when something looks wrong. To see how objects relate to each other:
flux tree kustomization flux-system
flux trace deployment webapp -n webapp
tree lists everything a Kustomization manages. trace goes the other way: given a live object, it shows which Kustomization and which Git source and revision it came from.
Reconcile on demand
Flux polls on an interval. To force it now:
flux reconcile source git flux-system
flux reconcile kustomization webapp --with-source
flux reconcile helmrelease podinfo -n podinfo
--with-source refreshes the Git source before applying, so a commit you just pushed is picked up immediately.
Preview before you push
Two commands render and compare without changing the cluster, which is useful in code review and CI:
flux build kustomization webapp --path ./apps/webapp --dry-run
flux diff kustomization webapp --path ./apps/webapp
build prints the manifests Flux would apply. diff compares them with what is running. Both read from a local folder, so run them from a clone of the repository.
Troubleshoot
flux logs --all-namespaces --level=error --follow
flux events --for Kustomization/webapp
kubectl describe kustomization webapp -n flux-system
flux logs streams controller logs, flux events shows Kubernetes events for a specific object, and kubectl describe shows an object’s conditions and latest error. Common causes of a failing Kustomization are a wrong path, a missing dependency (check dependsOn), invalid YAML, or a failed health check when wait: true is set. For a stuck GitRepository, describe usually shows an authentication error.
Create resources without writing YAML
Most flux create commands can print YAML instead of applying it. Commit the output to Git, which keeps everything declarative:
flux create source git webapp-config \
--url=https://github.com/your-org/webapp-config \
--branch=main --interval=1m --export > webapp-source.yaml
flux create kustomization webapp \
--source=GitRepository/webapp-config \
--path=./apps/webapp --prune=true --interval=10m --export > webapp.yaml
Without --export the command applies the object directly, which is fine for experiments but leaves the cluster out of step with Git. To dump existing objects as YAML, use flux export:
flux export source git --all
flux export kustomization --all
Pause, resume, and clean up
flux suspend kustomization webapp
flux resume kustomization webapp
flux delete kustomization webapp
flux uninstall
suspend stops reconciliation, and resume restarts it. delete removes the Kustomization, and with prune: true it also removes the resources it manages, so it can take a moment. uninstall removes Flux itself from the cluster. Run flux get kustomizations afterwards to confirm.
Handy extras
flux statssummarizes how many Flux resources exist and how many are ready.- Flux 2.9 added a CLI plugin system (
flux plugin) with plugins such asmirrorandschema. Runflux plugin --helpto see what your version offers. - Because there is no UI, many teams add Grafana dashboards or a community dashboard on top of the metrics Flux exposes.
Popular Guides
-
Push vs Pull: How Flux Delivers to Kubernetes Why pull-based, Git-driven delivery changes how you deploy, secure, and recover clusters. -
Deploy Your First Application with a GitRepository and Kustomization Point Flux at manifests in Git using a Kustomization resource and watch it sync. -
Control Sync Behavior: Intervals, Prune, Drift Correction, and Rollback Decide when Flux applies changes, what it deletes, how to pause it, and how to undo a bad deploy. -
Automate Image Updates with Flux Image Automation Let Flux detect new container image tags and commit them back to Git. -
Configure Multi-Cluster with Flux Manage several clusters from one repository, with shared infrastructure and per-cluster differences. -
Flux CD vs Argo CD: Choosing a GitOps Tool Compare architecture, UI, Helm, secrets, tenancy, and image automation to pick the right tool.