kustomize edit set image command into your CI/CD pipeline. By the end, you’ll understand how to automatically update your Kubernetes manifests with a new image tag whenever a build completes successfully.
Table of Contents
- CI/CD Pipeline Overview
- 1. Triggering the Pipeline
- 2. Installing Dependencies & Running Tests
- 3. Building & Tagging the Container Image
- 4. Updating Manifests with
kustomize edit - 5. Deploying to Kubernetes
- References
CI/CD Pipeline Overview
This is a typical flow for deploying code changes:Using a Git commit hash (or semantic version) as your Docker image tag ensures traceability between your code and the container you deploy.
1. Triggering the Pipeline
Any push to the main branch starts the CI/CD process. For example:2. Installing Dependencies & Running Tests
In the build stage, install dependencies and execute tests:3. Building & Tagging the Container Image
Most CI systems provide an environment variable for the commit SHA. For instance:myrepo/api:abcdef123 uniquely identifies the image corresponding to this commit.
4. Updating Manifests with kustomize edit
In the CD stage, adjust your Kustomize overlay so the manifest points to the new image tag:images section of your kustomization.yaml:
Ensure your
kustomization.yaml is under version control so you can track these automated updates. Avoid committing sensitive credentials or hardcoded tags.5. Deploying to Kubernetes
With your overlay updated, deploy the change to production:myrepo/api:abcdef123, and perform a rolling update.