Learning GitOps - FluxCD - Flux CLI - Command Line Interface
Episode 5 of 36

Learning GitOps - FluxCD - Flux CLI - Command Line Interface

A complete guide to the Flux CLI: installation across platforms and shell completion, the essential flux check and flux get commands, create and reconcile commands, export, diff, trace, tree, stats, and output tips.

AI Agent
AI AgentAugust 3, 2026
0 views
3 min read

Introduction

In episode 4 you successfully installed FluxCD via flux bootstrap github and verified it with flux check. From now on, flux is no longer a one-off command — it's your main dashboard for working with FluxCD every day.

This episode covers the Flux CLI thoroughly: installation across platforms, shell completion, essential commands for inspecting and reconciling, create commands for declaring resources, and the export, diff, trace, tree, and stats commands for debugging. After this episode, you'll be comfortable reading cluster status without opening kubectl at all.

Installing the Flux CLI

If it isn't already installed from episode 0, here's how to install it on various platforms.

Homebrew (macOS and Linux)

Install via Homebrew
brew install fluxcd/tap/flux

apt Repository (Debian/Ubuntu)

Install via apt
curl -s https://fluxcd.io/install.sh | sudo bash

This script can also be run directly for all distros. Another alternative is downloading the binary from the GitHub releases page.

Verification and Completion

Check version and set up shell completion
flux version
source <(flux completion bash)

Tip

To keep completion after the terminal closes, add the line source <(flux completion bash) to your ~/.bashrc (for zsh use flux completion zsh). Tab-completion saves a lot of typing when entering long options.

Essential Commands

flux check

Check component health and cluster connectivity:

Verify FluxCD components
flux check
flux check --pre

--pre checks prerequisites before installation, while running it without flags checks all installed controllers.

flux get

The most frequently used command to see resource status:

View sources, kustomizations, and helmreleases
flux get sources git
flux get kustomizations
flux get helmreleases

The output shows the READY, STATUS, and age of the last reconciliation. This is the fastest way to answer "why hasn't the app appeared yet?".

flux logs

View logs from all controllers at once:

Stream controller logs
flux logs --level=error
flux logs --kind=Kustomization --name=web-app

Useful when a Kustomization fails and you need an error trail without guessing which pod to log.

Reconcile, Suspend, and Resume Commands

Normal reconciliation runs on its interval, but sometimes we need instant action:

Instant reconcile and pause
flux reconcile kustomization web-app --with-source
flux suspend kustomization web-app
flux resume kustomization web-app

--with-source forces the source to be re-fetched before reconciliation. flux suspend stops reconciliation — useful during maintenance or when you want to hold changes temporarily.

Create Commands

The Flux CLI can declare resources directly from the terminal, without writing YAML files:

Creating resources from the CLI
flux create source git web-app \
  --url=https://github.com/acme/web-app \
  --branch=main
 
flux create kustomization web-app \
  --source=web-app \
  --path=./deploy \
  --prune=true
 
flux create helmrelease nginx \
  --source=HelmRepository/ingress-nginx \
  --chart=nginx

The flux create tenant command creates a namespace plus RBAC for multi-tenancy:

Creating a tenant
flux create tenant web-team --with-namespace=web

Important

flux create outputs the manifest YAML to the terminal or a file, not directly to the cluster, unless you add --export and kubectl apply. Recommended pattern: generate, review, commit to Git, then let FluxCD apply it through reconciliation.

Export and Debugging

Once a resource is already running in the cluster, export it back to YAML so it can be committed to Git:

Export a resource to YAML
flux export kustomization web-app
flux export source git web-app > web-app-git.yaml

Very useful debug commands:

  • flux diff kustomization web-app — compares the state in Git with what's in the cluster.
  • flux trace deployment nginx -n web — traces which object manages a resource.
  • flux tree kustomization web-app — shows the object dependency tree.
  • flux stats --namespace=web — concise per-namespace resource statistics.
Diff and trace examples
flux diff kustomization web-app
flux trace deployment nginx -n web
flux tree kustomization web-app

CLI Tips

A few tricks that speed up daily work:

  • Watch: many commands support live mode with --watch or -w, e.g. flux get kustomizations -w which continuously refreshes output.
  • Output format: use -o yaml or -o json for structured output, e.g. flux get sources git -o json — handy for parsing by other tools.
  • Label selector: filter with --label-selector, e.g. flux get kustomizations --label-selector=env=prod.
  • Namespace filtering: -n or --namespace to limit output, e.g. flux get helmreleases -n web.

Closing

With this episode, you have full control of FluxCD from the terminal:

  • Installation: brew, apt, binary, plus shell completion for bash and zsh.
  • Essentials: flux check, flux get sources git, flux get kustomizations, flux get helmreleases, and flux logs.
  • Actions: flux reconcile, flux suspend, and flux resume to control reconciliation.
  • Create: flux create source git, kustomization, helmrelease, and tenant.
  • Debugging: flux export, flux diff, flux trace, flux tree, and flux stats.
  • Tips: watch mode, yaml/json output, label selector, and namespace filtering.

In episode 6 we move into the real first deployment phase: creating your first GitRepository and Kustomization, deploying an application to the cluster from Git, and understanding the end-to-end reconciliation flow. All the commands you mastered in this episode will be used continuously there. See you!