What is Kustomize? Kubernetes Config Management Explained Simply
Kustomize lets you customize Kubernetes YAML without copying and editing files. Here's what it is, how it works, and when to use it instead of Helm.
You have the same Kubernetes app running in dev, staging, and prod. The only differences are: the image tag, the replica count, and a few environment variables.
Do you copy the YAML three times and edit each one? No. You use Kustomize.
What is Kustomize?
Kustomize is a tool built into kubectl that lets you customize Kubernetes YAML files without modifying the original. You define a base configuration and then apply overlays per environment.
No templates. No new syntax. Just plain Kubernetes YAML plus a kustomization.yaml file.
# Already built into kubectl
kubectl apply -k ./overlays/prod/
# Or use the standalone binary
kustomize build ./overlays/prod/ | kubectl apply -f -The Problem Kustomize Solves
Imagine this structure without Kustomize:
k8s/
dev/
deployment.yaml # replicas: 1, image: myapp:dev
service.yaml
configmap.yaml
prod/
deployment.yaml # replicas: 5, image: myapp:v1.2.3
service.yaml
configmap.yaml
Six files. Most of them are 90% identical. When you change the Service port, you change it in two places. When you add a label, you add it in two places.
Kustomize fixes this.
How Kustomize Works
Base + Overlay Model
k8s/
base/
deployment.yaml # shared config
service.yaml
kustomization.yaml # lists what's in base
overlays/
dev/
kustomization.yaml # patches for dev
prod/
kustomization.yaml # patches for prod
replica-patch.yaml # specific prod changes
The Base
k8s/base/deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:latest
ports:
- containerPort: 8080k8s/base/kustomization.yaml:
resources:
- deployment.yaml
- service.yamlThe Prod Overlay
k8s/overlays/prod/kustomization.yaml:
bases:
- ../../base
images:
- name: myapp
newTag: v1.2.3 # override the image tag
patches:
- path: replica-patch.yaml
commonLabels:
environment: productionk8s/overlays/prod/replica-patch.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 5 # override replicas for prodDeploy to Prod
kubectl apply -k k8s/overlays/prod/Kustomize merges the base + overlay and applies the result. The base files are never modified.
Common Kustomize Features
1. Image Tag Override
# kustomization.yaml
images:
- name: myapp
newTag: "$(IMAGE_TAG)" # works with CI/CD variables# In your CI pipeline:
kustomize edit set image myapp:$CI_COMMIT_SHA
kubectl apply -k .2. ConfigMap Generator
Instead of writing a ConfigMap YAML, generate it from a file:
# kustomization.yaml
configMapGenerator:
- name: app-config
files:
- config/app.properties
literals:
- APP_ENV=production
- LOG_LEVEL=infoKustomize auto-appends a hash to the name (app-config-abc123) so pods restart automatically when config changes.
3. Namespace Override
# kustomization.yaml
namespace: production # applies to all resources4. Common Labels and Annotations
# kustomization.yaml
commonLabels:
team: backend
app: myapp
commonAnnotations:
managed-by: kustomize5. Strategic Merge Patch vs JSON Patch
Strategic Merge Patch (easiest — just write partial YAML):
# replica-patch.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 5JSON 6902 Patch (more precise):
# kustomization.yaml
patches:
- target:
kind: Deployment
name: myapp
patch: |-
- op: replace
path: /spec/replicas
value: 5Kustomize vs Helm
| Kustomize | Helm | |
|---|---|---|
| Syntax | Plain YAML | Go templates |
| Learning curve | Low | Medium |
| Package management | No | Yes (charts) |
| Versioning/rollback | Via Git | Built-in |
| Community charts | No | Thousands |
| GitOps (ArgoCD/Flux) | Native support | Supported |
Use Kustomize when:
- You own the app and manage the YAML
- You want simple environment-specific overrides
- You're using GitOps with ArgoCD or Flux
Use Helm when:
- You're installing third-party software (Prometheus, Nginx, etc.)
- You need parameterized charts shared across teams
- You want versioned releases with rollback
Many teams use both: Helm to install third-party tools, Kustomize to manage their own apps.
With ArgoCD
ArgoCD has native Kustomize support:
# ArgoCD Application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp-prod
spec:
source:
repoURL: https://github.com/myorg/k8s-configs
targetRevision: main
path: overlays/prod # ArgoCD runs kustomize build here
destination:
server: https://kubernetes.default.svc
namespace: productionWhen you push a new image tag to the overlay, ArgoCD detects the change and syncs automatically.
Quick Start in 5 Minutes
# Install kustomize
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
# Preview what will be applied (dry run)
kustomize build overlays/prod/
# Apply
kubectl apply -k overlays/prod/
# Diff against live cluster
kubectl diff -k overlays/prod/Kustomize is one of those tools that feels unnecessary until you have 3+ environments, then it becomes essential. Start with the base + overlay pattern and you'll never go back to copy-pasting YAML.
For a full Kubernetes configuration management course including Kustomize and Helm labs, check out KodeKloud.
Stay ahead of the curve
Get the latest DevOps, Kubernetes, AWS, and AI/ML guides delivered straight to your inbox. No spam — just practical engineering content.
Related Articles
Build a Kubernetes Cluster with kubeadm from Scratch (2026)
Step-by-step guide to building a real multi-node Kubernetes cluster using kubeadm — no managed services, no shortcuts.
How to Build a DevOps Home Lab for Free in 2026
You don't need expensive hardware to practice DevOps. Here's how to build a complete home lab with Kubernetes, CI/CD, and monitoring using free tools and cloud free tiers.
How to Crack the CKA Exam in 2026: Study Plan, Resources, and Tips
Complete CKA exam prep guide for 2026 — what to study, how to practice, which resources actually help, and tips to pass on the first attempt.