In this article, we explore how to modify container images in Kubernetes manifests using Kustomize image transformers. This powerful technique enables you to update image references—and even image tags—in your deployment files without editing them manually. Below is an example deployment manifest (deployment.yaml) for an Nginx server:Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
kustomization.yaml. In the transformer, the name property specifies the image to search for (in this case, “nginx”), and the newName property defines the replacement image. For example, to replace Nginx with HAProxy, use the following configuration:
The
name field in the kustomization.yaml file strictly refers to the image name and is not related to the container name specified in the deployment manifest.Changing the Image Tag
If you want to update only the image tag without switching the image itself, the image transformer can modify the tag value. Begin with the original deployment manifest:kustomization.yaml to specify the new tag:
Combining Image and Tag Transformations
You can perform both image name and tag transformations simultaneously in a singlekustomization.yaml file. For instance, if you want to change the Nginx image to HAProxy and update its tag to “2.4,” use the following configuration:
This guide demonstrates how to leverage Kustomize’s image transformer for efficient container image and tag modifications, ensuring a consistent deployment process while minimizing manual edits.