Skip to content

Lesson 2 of 9 · 25m

The Flux Operating Model

Operate Flux through source and reconciliation objects, dependency ordering, server-side apply, and explicit force-reconciliation when recovery requires it.

Flux feels invisible when it is healthy. It is also extremely literal. Teams get into trouble when they think of it as a CI job that applies folders. Flux is a set of Kubernetes controllers watching source objects, building manifests, applying them, and recording readiness. Once you operate those objects directly instead of treating the cluster as a black box, incidents become much shorter.

Sources produce artifacts; Kustomizations consume them

A minimal bootstrap uses a GitRepository and a Kustomization:

apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata: {name: platform, namespace: flux-system}
spec:
  interval: 1m
  url: ssh://git@github.com/SudoSecurityOrg/platform.git
  ref: {branch: main}
  secretRef: {name: flux-ssh}
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata: {name: apps, namespace: flux-system}
spec:
  interval: 10m
  retryInterval: 1m
  path: ./clusters/prod/apps
  prune: true
  sourceRef: {kind: GitRepository, name: platform}
  validation: client

The GitRepository answers "where does truth come from?" The Kustomization answers "which part of truth should this cluster own?" Keep those questions separate during troubleshooting. When order matters, declare spec.dependsOn rather than relying on filenames or wishful thinking.

Flux applies by default and prunes when told

With prune: true, removing a resource from the rendered path eventually removes it from the cluster. Without pruning, deletion in Git is only a disappearing declaration, not necessarily a deletion in the cluster. That difference has caused more than one "I deleted the compromised namespace but it still exists" moment.

Server-side apply also matters. Flux owns fields through a field manager. If another controller edits the same field, you can see persistent diff noise or apply conflicts:

flux get kustomizations -A
kubectl -n flux-system describe kustomization apps
flux logs --level=error --follow
kubectl -n flux-system get events --sort-by=.lastTimestamp

Force reconciliation deliberately

Flux reconciles on interval and source updates. During recovery, force the exact dependency chain:

flux reconcile source git platform
flux reconcile kustomization crds
flux reconcile kustomization apps --with-source

--with-source is useful when the commit has landed but the artifact cache has not refreshed. It is not a universal incantation; read the error first. A failed source fetch, a bad kustomize build, schema validation failure, and RBAC denial all need different fixes.

Field notes

  • flux suspend and flux resume affect the object you target, not the entire universe unless you target the root chain.
  • A ready source plus failing kustomization means fetching works but building or applying does not.
  • Never solve persistent field conflicts by blindly forcing apply; determine which controller owns the field.
  • Keep bootstrap credentials narrowly scoped. Flux often needs powerful write access inside the cluster, not powerful write access everywhere else.
  • If prune scares you, that fear is healthy. Test deletions in a non-production cluster before enabling it broadly.

Was this lesson helpful?

Sign in to rate