Example Deployment
Consider the following deployment that uses an Nginx container. This configuration is defined in a file nameddeployment.yaml:
Transforming the Image
To transform the image used by the deployment, create akustomization.yaml file that specifies the desired image transformation. For example, if you want to replace the Nginx image with HAProxy, your kustomization.yaml should include the following configuration:
The “name” property in the kustomization file is related to the image reference and is separate from the container name (which is “web” in the deployment manifest). This is a common point of confusion.
Updating Only the Image Tag
If your goal is to update only the image tag, you can do so by using thenewTag property. For instance, to change the tag of the nginx image to “2.4”, your kustomization.yaml should be written as follows:
Combining Image Name and Tag Changes
You can also combine both thenewName and newTag properties if you wish to replace the image entirely and update its tag in one step. For example, to change the nginx image to HAProxy with the tag “2.4”, your kustomization.yaml would include both properties:
haproxy:2.4.
By leveraging Kustomize’s image transformer, you can manage image updates efficiently without directly altering your Kubernetes manifests. This process simplifies deployment updates and ensures consistency across your environments.