Skip to main content
In this lesson you’ll learn how to use Kustomize’s image transformer to update container images (name and/or tag) in Kubernetes manifests without editing the original resource files. This is especially useful for environment-specific overrides, CI/CD pipelines, or replacing images across many manifests in a single place. Below are concise, practical examples that show:
  • a Deployment manifest (original),
  • Kustomize images: transformations (in kustomization.yaml),
  • the resulting rendered manifests after running kustomize build or kubectl kustomize.

Initial Deployment (deployment.yaml)

Example 1 — Replace the image name (newName)

kustomization snippet that replaces the base image name nginx with haproxy:
How to preview or apply the transformation:
Rendered Deployment after applying the newName transform:
Note: The name field under images: in kustomization.yaml matches the image reference (for example nginx), not the container name in the Pod/Deployment spec. The container’s name: web is independent and does not affect Kustomize image matching.

Example 2 — Change only the tag (newTag)

If you want to keep the same image name but change the tag:
Rendered Deployment after applying the newTag transform:

Example 3 — Change both name and tag (newName + newTag)

To replace both the image name and the tag in one transform:
Rendered Deployment after applying both newName and newTag:

Quick reference table

Additional notes and best practices

  • You can include multiple entries in the images: list to transform several different base images in one kustomization.yaml.
  • Matching is strict: use the same base reference as in your manifests (for example nginx, nginx:1.21, or a full registry path like gcr.io/myproj/nginx) to ensure replacements occur as expected.
  • Always preview transformations with kustomize build or kubectl kustomize before applying them with kubectl apply -k ..
  • Use Kustomize overlays (separate kustomization directories) for environment-specific image overrides (dev, staging, prod) to keep base manifests immutable.

Watch Video