Skip to main content
In this guide, you’ll learn how to integrate the 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

  1. CI/CD Pipeline Overview
  2. 1. Triggering the Pipeline
  3. 2. Installing Dependencies & Running Tests
  4. 3. Building & Tagging the Container Image
  5. 4. Updating Manifests with kustomize edit
  6. 5. Deploying to Kubernetes
  7. 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:
Your CI system (GitHub Actions, Jenkins, GitLab CI, etc.) detects the new commit and enters the build stage.

2. Installing Dependencies & Running Tests

In the build stage, install dependencies and execute tests:
If all tests pass, the pipeline moves on to building the Docker image.

3. Building & Tagging the Container Image

Most CI systems provide an environment variable for the commit SHA. For instance:
Here, 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:
This command modifies the 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:
Kubernetes will detect the new image tag, pull myrepo/api:abcdef123, and perform a rolling update.

References

Watch Video

Practice Lab