Kustomize Edit commands

21 commands in 3 groups: Resources & Patches, Images & Transformers, Generators. Click or tap any command to copy it. Part of the full Kustomize cheat sheet. Official documentation: kubectl.docs.kubernetes.io.

Open in the interactive cheat sheet search, stars and every other section

Resources & Patches

Add or remove resource files and patches directly in kustomization.yaml.
kustomize edit add resource <file.yaml>
Add a resource file to kustomization
kustomize edit remove resource <file.yaml>
Remove a resource from kustomization
kustomize edit add patch --path <patch.yaml>
Add a patch file (strategic merge or JSON 6902) to the patches field
kustomize edit remove patch --path <patch.yaml>
Remove a patch (pass the same target flags used to add it)
kustomize edit add patch --path <patch.yaml> --kind <Kind>
Add a patch scoped to a specific resource kind

Images & Transformers

Override images, set namespace, add name prefix or suffix, and attach common labels and annotations.
kustomize edit add annotation <key>:<value>
Add a common annotation to all resources
kustomize edit fix
Auto-migrate kustomization.yaml to current syntax
kustomize edit set image <name>:<tag>
Override only the tag of an image
kustomize edit set image <name>=<new-image>:<tag>
Override image name and tag
kustomize edit set nameprefix <prefix>-
Add prefix to all resource names
kustomize edit set namespace <ns>
Set namespace for all resources
kustomize edit set namesuffix -- -<suffix>
Add suffix to all resource names
kustomize edit set replicas <name>=<count>
Override replica count for a resource
kustomize edit add label <key>:<value> --without-selector
Add a label to all resources (labels field, selectors untouched)

Generators

Register ConfigMap and Secret generators that produce resources from literals, files, or env files.
kustomize edit remove configmap <name>
Remove a ConfigMap generator
kustomize edit remove secret <name>
Remove a Secret generator
kustomize edit add configmap <name> --from-env-file=<file>
Add a ConfigMap generator from an env file
kustomize edit add configmap <name> --from-file=<file>
Add a ConfigMap generator from a file
kustomize edit add configmap <name> --from-literal=<key>=<value>
Add a ConfigMap generator from a literal value
kustomize edit add secret <name> --from-file=<file>
Add a Secret generator from a file
kustomize edit add secret <name> --from-literal=<key>=<value>
Add a Secret generator from a literal value