Kustomize cheat sheet

Every Kustomize command on kube.how in one place: 34 in 2 sections, Manage and Edit. Click or tap any command to copy it.

Kustomize Manage commands

Install Kustomize

Kustomize customizes raw Kubernetes YAML without templates. It is built into kubectl (apply -k) and available as a standalone CLI.
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
Install via official script into the current directory (Linux / macOS)
brew install kustomize
Install via Homebrew (macOS / Linux with brew)
kustomize version
Verify installation and show build info

Manage

Render a kustomization overlay and apply it to the cluster. Use kubectl -k flags for the native built-in path, or pipe kustomize build for full control.
kubectl apply -k <dir>
Apply overlay using kubectl built-in kustomize
kustomize build <dir>
Render overlay to stdout
kustomize build <dir> > output.yaml
Write rendered manifests to a file
kustomize build <dir> --enable-helm
Render overlay with embedded Helm chart support
kustomize build <dir> | kubectl apply -f -
Render and apply to cluster
kustomize build <dir> | kubectl delete -f -
Render and delete from cluster
kustomize build <dir> | kubectl apply --server-side -f -
Render and apply with server-side apply (avoids annotation size limits)
kubectl delete -k <dir>
Delete resources defined by overlay
kubectl kustomize <dir> | kubectl apply -f -
Render with kubectl built-in, then apply

List & Inspect

Render an overlay locally to inspect the output without applying it.
kubectl kustomize <dir>
Render overlay with kubectl built-in (no apply)

Kustomize Edit commands

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