kustomize "invalid Kustomization: apiVersion not found" in CI
A kustomization.yaml should declare apiVersion: kustomize.config.k8s.io/v1beta1 and kind: Kustomization. A wrong or missing header, or unknown fields for that version, makes kustomize reject the file or misparse it.
What this error means
kustomize build fails with "invalid Kustomization: apiVersion: Invalid value" or unmarshals unknown fields, often after copying a header from another manifest type.
Error: invalid Kustomization: json: unknown field "spec"
apiVersion: kustomize.config.k8s.io/v1beta1
kind: KustomizationCommon causes
The wrong apiVersion or kind header
A header borrowed from a different resource, or a missing kind, means kustomize does not treat the file as a Kustomization.
Fields that do not belong in a kustomization
A spec: or other manifest field pasted into kustomization.yaml is unknown to the Kustomization schema and rejected.
How to fix it
Use the correct kustomization header
- Set
apiVersion: kustomize.config.k8s.io/v1beta1andkind: Kustomization. - Remove any fields that belong to Kubernetes manifests, not kustomizations.
- Rebuild to confirm the file parses.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yamlKeep only kustomization fields
Move manifest content into referenced resource files; kustomization.yaml holds only kustomize directives.
How to prevent it
- Start kustomizations from the canonical header.
- Keep manifest fields in resource files, not in kustomization.yaml.
- Build in CI so header and field errors surface before apply.