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.
namespaces "apps" not foundCommon 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
- Include the Namespace in an infrastructure Kustomization.
- Make the workload Kustomization depend on it via
spec.dependsOn. - Reconcile the dependency, then the workloads.
spec:
dependsOn:
- name: infrastructure
flux reconcile kustomization apps --with-sourceConfirm the namespace exists
Check whether the target namespace was actually created before the workloads apply.
kubectl get ns appsHow 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.