Skip to content
Latchkey

Flux Kustomization "namespace not found" in CI

kustomize-controller tried to apply resources into a namespace that does not exist. The namespace is defined in another Kustomization or manifest that has not reconciled yet, so the apply fails for the namespaced objects.

What this error means

A Kustomization reports "False" with "namespaces 'apps' not found" when the workloads target a namespace no earlier Kustomization has created.

kustomize-controller
namespaces "apps" not found

Common causes

The namespace is created by a later or unordered Kustomization

The workload Kustomization runs before the one that creates the namespace, so the target does not exist at apply time.

The Namespace manifest is missing entirely

No manifest creates the namespace, so it never exists and every apply into it fails.

How to fix it

Create the namespace and order it first

  1. Include the Namespace in an infrastructure Kustomization.
  2. Make the workload Kustomization depend on it via spec.dependsOn.
  3. Reconcile the dependency, then the workloads.
kustomization.yaml
spec:
  dependsOn:
    - name: infrastructure
flux reconcile kustomization apps --with-source

Confirm the namespace exists

Check whether the target namespace was actually created before the workloads apply.

Terminal
kubectl get ns apps

How to prevent it

  • Create namespaces in an infrastructure layer that runs before workloads.
  • Use dependsOn so namespaced resources apply only after the namespace exists.
  • Keep a Namespace manifest for every namespace you deploy into.

Frequently asked questions

What causes ""namespaces ... not found""?
The workload Kustomization runs before the one that creates the namespace, so the target does not exist at apply time.
How do I fix "namespaces ... not found"?
Create the namespace and order it first

Related guides

References

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