- The repo contains a
manifestfolder with two top-level directories:helmandkustomize. - Inside
kustomizethere arebaseandoverlaysfolders.baseholds canonical manifests (Deployment, Service, Namespace) and akustomization.yml.overlaysinclude environment-specific patches (e.g.,dev,prod) that Kustomize applies on top of the base.

- The
base/kustomization.ymllists the core manifests to be managed as the canonical source:
base/deployment.ymldefines the default configuration: image tagblue, labels, and a single replica:
- Overlays reference the
baseand apply environment-specific changes using Kustomize patches and per-overlay kustomization files (for example,overlays/dev/kustomization.ymlandoverlays/prod/kustomization.yml). - Typical overlay changes include replica counts, environment variables, image tags, and namespace assignments.
overlays/dev/kustomization.ymlpoints to the base and applies two patches (replica and env), and forces resources into thekustomize-devnamespace:
overlays/dev/replica-patch.ymlsets the dev replica count:
overlays/dev/env-patch.ymlupdates the container environment variable. Note that the containernamemust match the base so Kustomize can perform a strategic merge correctly:
Kustomize performs a strategic merge when applying patches. Always include the container
name in your patch when modifying container-level fields (env, image, ports, etc.) so Kustomize can match and update the correct container.overlays/prod/kustomization.ymlreferences the same base, setskustomize-prodas the namespace, and applies three patches (replicas, env, image):
- Replica patch (
overlays/prod/replica-patch.yml):
- Env patch (
overlays/prod/env-patch.yml):
- Image patch (
overlays/prod/image-patch.yml):
- With overlays in Git, create an Argo CD Application per environment that targets the overlay path (for example,
manifest/kustomize/overlays/devfor dev). - Recommended Argo CD settings:
- App name:
kustomize-dev(orkustomize-prodfor production) - Repo path:
manifest/kustomize/overlays/dev(or.../overlays/prod) - Sync policy: automatic (if you want continuous reconciliation)
- Option: enable auto-create namespace (or let Kustomize create it via
namespace.ymlinbase)
- App name:

- Creating the Argo CD Application for
overlays/devresults in Argo CD applying:- The base resources
- The dev overlay patches (replicas and env)
- The
kustomize-devnamespace (if configured)
- The Application should show as Synced and Healthy after the cluster converges.

- The base Deployment had
replicas: 1andPOD_COUNT: "1". - The dev overlay patches change replicas to
2andPOD_COUNTto"2". - The prod overlay sets replicas to
5,POD_COUNTto"5", and updates the image togreen.
| Resource / Field | Base | Dev overlay result | Prod overlay result |
|---|---|---|---|
| Namespace | default (or none) | kustomize-dev | kustomize-prod |
replicas | 1 | 2 | 5 |
POD_COUNT env var | "1" | "2" | "5" |
| Image | siddharth67/highway-animation:blue | siddharth67/highway-animation:blue | siddharth67/highway-animation:green |
| Example NodePort (Service) | — | 30906 (example) | 30247 (example) |
- The live Deployment in
kustomize-devwill reflect the merged configuration:
- If the Service is exposed via NodePort, use the node IP and NodePort (for example,
http://<NODE_IP>:30906) to reach the dev application. - Dev pods will use the
blueimage; prod pods will usegreenif the prod image patch is applied.
- Create a separate Argo CD Application pointing at
manifest/kustomize/overlays/prod. Argo CD will apply prod patches:replicas: 5,POD_COUNT: "5", andimage: ...:green. The live prod Deployment will reflect these changes and scale accordingly.
- Kustomize enables one canonical base with environment-specific overlays—no templating required.
- Use strategic merge patches in overlays to modify the base; include
containers[].namewhen patching container fields to ensure accurate merges. - Use Argo CD to point to overlay paths so each environment is an independent Argo CD Application that continuously reconciles Git → cluster (GitOps).
- Organize overlays clearly (e.g.,
dev,staging,prod) and keep patches small and focused (replicas, env, image).
When writing Kustomize patches that modify container fields (env, image, etc.), include the container
name in the patch so Kustomize can match and merge the correct container entry.