Skip to content
LatchkeyLatchkey home

flux create kustomization: Apply from a Source

flux create kustomization creates a Kustomization object that applies a path from a source and keeps it reconciled.

A Kustomization is Flux's apply loop: it takes a path inside a source and continuously applies it to the cluster.

What it does

flux create kustomization defines a Kustomization custom resource that references a --source (a GitRepository or OCIRepository), applies the manifests under --path, and reconciles on --interval. --prune deletes resources removed from the source.

Common usage

Terminal
flux create kustomization podinfo \
  --source=GitRepository/podinfo \
  --path=./kustomize \
  --prune=true \
  --interval=5m \
  --wait=true

Options

FlagWhat it does
--source <kind/name>Source to apply from (e.g. GitRepository/podinfo)
--path <dir>Directory in the source to apply
--pruneGarbage-collect resources removed from the source
--interval <dur>Reconcile interval
--waitWait for applied resources to become Ready
--depends-on <name>Order this after another Kustomization

In CI

Set --prune=true so deletions in Git propagate to the cluster. --wait=true makes the Kustomization report Ready only when its workloads are healthy, which combined with flux reconcile gives a synchronous deploy you can gate on.

Common errors in CI

"✗ Kustomization reconciliation failed: kustomize build failed: ... no such file or directory" means --path is wrong. "dry-run failed: ... is forbidden" means RBAC denies the service account that field. "✗ source not found" means the --source kind/name does not match an existing source object.

Using this in CI

A runner has no kubeconfig, no cached context, and no interactive auth. Every kubectl invocation in CI needs the context supplied explicitly, and most confusing CI failures here are the command running against the wrong cluster or no cluster at all.

Terminal
# never rely on the ambient context on a runner
kubectl --context "$KUBE_CONTEXT" -n "$NAMESPACE" get pods

# confirm what you are actually connected to before mutating anything
kubectl config current-context
kubectl cluster-info

# fail fast instead of hanging on an unreachable API server
kubectl --request-timeout=30s get nodes

Frequently asked questions

flux create kustomization: Apply from a Source?
A Kustomization is Flux's apply loop: it takes a path inside a source and continuously applies it to the cluster.
What it does?
flux create kustomization defines a Kustomization custom resource that references a --source (a GitRepository or OCIRepository), applies the manifests under --path, and reconciles on --interval. --prune deletes resources removed from the source.
In CI?
Set --prune=true so deletions in Git propagate to the cluster. --wait=true makes the Kustomization report Ready only when its workloads are healthy, which combined with flux reconcile gives a synchronous deploy you can gate on.
Common errors in CI?
"✗ Kustomization reconciliation failed: kustomize build failed: ... no such file or directory" means --path is wrong. "dry-run failed: ... is forbidden" means RBAC denies the service account that field. "✗ source not found" means the --source kind/name does not match an existing source object.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card