Skip to content
Latchkey

kustomize create: Scaffold a kustomization.yaml

kustomize create writes a new kustomization.yaml into the current directory so you can start an overlay or base.

Rather than hand-typing the file, create stamps out a valid kustomization.yaml. --autodetect picks up the YAML already in the folder.

What it does

kustomize create generates a kustomization.yaml in the working directory. With no flags it writes an almost-empty file; --autodetect scans the directory for manifests and lists them under resources; --resources adds named files.

Common usage

Terminal
kustomize create
kustomize create --autodetect
kustomize create --resources deployment.yaml,service.yaml --namespace web

Flags

FlagWhat it does
--resources <list>Comma-separated files to add to the resources field
--autodetectAdd all YAML manifests found in the directory as resources
--recursiveWith --autodetect, also descend into subdirectories
--namespace <ns>Set the namespace field
--nameprefix / --namesuffixSet namePrefix or nameSuffix
--annotations / --labelsSeed commonAnnotations or labels

In CI

create is for scaffolding, not pipelines. In CI you commit the kustomization.yaml and run kustomize build or kubectl apply -k against it. Pin the kustomize version on the runner so the generated file shape stays stable.

Common errors in CI

"kustomization file already exists" means a kustomization.yaml is already present; create refuses to overwrite. "must build at directory: not a valid directory" later in the pipeline usually means create was never run or the file is named Kustomization with different casing than the loader expects (kustomization.yaml, kustomization.yml, or Kustomization).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →