Skip to main content
Leverage Kustomize’s image transformer to override container images in your Kubernetes manifests without touching the original YAML files. This approach keeps your base configurations DRY and promotes reusability across environments.

Prerequisites

  • Kubernetes cluster or local setup (e.g., Docker Desktop, Minikube)
  • kubectl v1.18+
  • Kustomize v3.2+ (bundled with kubectl since v1.14)
For more details, see Kubernetes Documentation and Kustomize Official Guide.

1. Replace the Image Name

Suppose you have a Deployment manifest (deployment.yaml) deploying an NGINX container:
To swap nginx for haproxy, create a kustomization.yaml in the same directory:
Run the build command:
Kustomize will find every nginx image reference and replace it with haproxy. The rendered Deployment becomes:
The name field under images matches the image name from your resources, not the container name in the Pod spec.

2. Change Only the Image Tag

If you want to keep nginx but bump its version tag to 2.4, specify newTag instead:
After kustomize build ., the Deployment’s container image updates to:

3. Combine Image Name and Tag Changes

You can simultaneously override both the repository and the tag:
The resulting manifest will then reference haproxy:2.4:

Image Transformer Fields

Omitting both newName and newTag in an images entry has no effect. Ensure at least one property is set.

Watch Video