Skip to content
Latchkey

kustomize edit: set image, add & CI Errors

Programmatically edit a kustomization.yaml - ideal for CI image bumps.

kustomize edit modifies the kustomization.yaml in place, so CI can set the freshly built image tag (or add resources) without fragile sed/YAML hacking.

What it does

kustomize edit runs from inside a kustomization directory and mutates its kustomization.yaml: edit set image updates an image name/tag/digest, edit add resource adds a file, edit set namespace sets the namespace. The classic CI use is pinning the image to the commit SHA the pipeline just built.

Common usage

Terminal
# Pin the image to the build’s tag (run inside the overlay dir)
cd overlays/prod
kustomize edit set image myapp=registry.example.com/myapp:${GIT_SHA}

# Add a resource and set the namespace
kustomize edit add resource service.yaml
kustomize edit set namespace prod

Common error in CI: must be run in a kustomization dir

edit fails with "unable to find one 'kustomization.yaml' in directory" when the step runs from the wrong path, or set image silently no-ops if the image name does not match one referenced in the manifests. Fix: cd into the directory that contains kustomization.yaml before running edit (it edits the file in the current dir), and use the exact image name as it appears in the manifests so the images: override actually applies. Commit or pipe the result; edit changes the file but does not deploy.

Key subcommands

SubcommandPurpose
set image NAME=REFSet an image name/tag/digest
set namespace NSSet the namespace
add resource FILEAdd a resource
set nameprefix / namesuffixSet a name prefix/suffix

Related guides

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