Skip to content
Latchkey

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.

kustomize
Error: invalid Kustomization: json: unknown field "spec"
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

Common 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

  1. Set apiVersion: kustomize.config.k8s.io/v1beta1 and kind: Kustomization.
  2. Remove any fields that belong to Kubernetes manifests, not kustomizations.
  3. Rebuild to confirm the file parses.
kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - deployment.yaml

Keep 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →