devops-basics

1. What is FluxCD?

Overview

Flux is a CNCF-graduated, GitOps continuous delivery tool for Kubernetes. It keeps a cluster’s state in sync with a source of truth stored in Git (or an OCI artifact / Helm repository) β€” you declare what you want deployed, Flux reconciles the cluster to match, on a schedule and automatically, with no kubectl apply in your deploy pipeline.

Flux is built as a set of specialized Kubernetes controllers, each with its own CRDs:

This is the same category as ArgoCD (see the argocd topic) β€” both are GitOps engines for Kubernetes β€” but Flux is CLI/CRD-first (no bundled UI by default) and composes independent controllers you can install individually, rather than one monolithic application.

FluxCD Architecture

 Git repo / Helm repo / OCI repo / S3 bucket
             β”‚
             β”‚ polls on --interval
             β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚  source-controller β”‚  fetches + verifies, exposes as a
     β”‚                    β”‚  versioned "Artifact"
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ Artifact (revision)
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚ kustomize-controllerβ”‚        β”‚   helm-controller     β”‚
     β”‚  applies Kustomize   β”‚       β”‚  installs/upgrades    β”‚
     β”‚  overlays, prunes    β”‚       β”‚  HelmReleases         β”‚
     β”‚  removed resources   β”‚       β”‚                       β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚                                 β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β–Ό
                        Kubernetes cluster
                                β”‚
                                β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚  notification-controller  β”‚  events out (Slack/
                  β”‚                           β”‚  webhook), triggers in
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Official Documentation

2. Prerequisites

3. Installation

How to install the Flux CLI?

# macOS / Linux
curl -s https://fluxcd.io/install.sh | sudo bash

# macOS via Homebrew
brew install fluxcd/tap/flux

# Verify
flux version --client

Check your cluster is ready for Flux

flux check --pre

4. Basics of FluxCD

Getting started with FluxCD

FluxCD Hello World

# Install Flux's controllers (source, kustomize, helm, notification)
flux install

# Point Flux at a Git repo β€” no PAT needed for a public repo
flux create source git podinfo \
  --url=https://github.com/stefanprodan/podinfo \
  --branch=master \
  --interval=1m

# Tell Flux to apply a path from that repo, and keep the cluster in sync
flux create kustomization podinfo \
  --target-namespace=default \
  --source=podinfo \
  --path="./kustomize" \
  --prune=true \
  --interval=10m

# Watch it reconcile
flux get sources git
flux get kustomizations
kubectl get deployments -n default

5. Beyond the Basics

flux bootstrap β€” the production pattern

The commands above (flux create source git + flux create kustomization) are the fastest way to see Flux work, but production setups almost always use flux bootstrap, which additionally:

export GITHUB_TOKEN=<your-pat>
flux bootstrap github \
  --owner=<your-github-username> \
  --repository=<your-fleet-repo> \
  --branch=main \
  --path=clusters/my-cluster \
  --personal

Multi-tenancy and multiple environments

Flux’s Kustomization and GitRepository are namespaced CRDs, so a common pattern is one flux-system per cluster with per-team or per-environment Kustomizations pointing at different paths (clusters/staging, clusters/production) of the same monorepo β€” see the official multi-tenancy guide.

Automating image updates

Flux’s image automation controllers can watch a container registry and open a commit against your Git repo whenever a new image tag matching a policy is pushed β€” closing the loop from CI (build+push image) to CD (Flux picks it up) without a separate deploy step.

Hands-On Examples

6. More

FluxCD Cheatsheet

# Sources
flux get sources git                    # list Git sources and their sync status
flux reconcile source git podinfo       # force an immediate re-sync

# Kustomizations
flux get kustomizations                 # list Kustomizations and their apply status
flux reconcile kustomization podinfo    # force an immediate re-apply
flux suspend kustomization podinfo      # pause reconciliation
flux resume kustomization podinfo       # resume reconciliation

# Everything at once
flux get all -A

# Logs (useful when a Kustomization is stuck)
flux logs --follow --tail=50

# Tear down
flux delete kustomization podinfo
flux delete source git podinfo
flux uninstall --namespace=flux-system