Helm uses templates with Go syntax. Kustomize uses overlays ā start with base manifests and patch them per environment. No template language. No curly braces. Just YAML.
How Kustomize Works
base/ overlays/staging/ overlays/production/
āāā deployment.yaml āāā kustomization.yaml āāā kustomization.yaml
āāā service.yaml āāā patch-replicas.yaml āāā patch-replicas.yaml
āāā kustomization.yaml āāā patch-resources.yamlBase manifests define the application. Overlays modify specific fields per environment.
Base
# base/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-api
spec:
replicas: 1
selector:
matchLabels:
app: order-api
template:
metadata:
labels:
app: order-api
spec:
containers:
- name: order-api
image: myorg/order-api:latest
ports:
- containerPort: 8080
resources:
requests:
cpu: 100m
memory: 128Mi# base/service.yaml
apiVersion: v1
kind: Service
metadata:
name: order-api
spec:
selector:
app: order-api
ports:
- port: 8080# base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yamlStaging Overlay
# overlays/staging/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namePrefix: staging-
namespace: staging
patches:
- path: patch-replicas.yaml
images:
- name: myorg/order-api
newTag: v1.2.0-rc1# overlays/staging/patch-replicas.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-api
spec:
replicas: 2Master this topic with hands-on labs
Go beyond reading ā build real projects in sandboxed environments with expert video guidance.
Browse Courses āProduction Overlay
# overlays/production/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namePrefix: prod-
namespace: production
patches:
- path: patch-replicas.yaml
- path: patch-resources.yaml
images:
- name: myorg/order-api
newTag: v1.1.0# overlays/production/patch-replicas.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-api
spec:
replicas: 5
# overlays/production/patch-resources.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-api
spec:
template:
spec:
containers:
- name: order-api
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: "1"
memory: 1GiApply
# Preview staging output
kubectl kustomize overlays/staging/
# Apply staging
kubectl apply -k overlays/staging/
# Apply production
kubectl apply -k overlays/production/ConfigMap and Secret Generators
# kustomization.yaml
configMapGenerator:
- name: app-config
literals:
- LOG_LEVEL=info
- PORT=8080
files:
- config.json
secretGenerator:
- name: db-credentials
literals:
- DB_HOST=postgres.production
- DB_PASSWORD=s3cur3Kustomize appends a hash suffix to ConfigMap/Secret names. When content changes, the name changes, triggering a pod rollout automatically.
Get weekly IT automation tips
Docker, Ansible, Terraform, MLOps ā curated insights delivered to your inbox. No spam.
Subscribe Free āStrategic Merge Patches
# Add a sidecar
patches:
- patch: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-api
spec:
template:
spec:
containers:
- name: log-shipper
image: fluent/fluent-bit:latest
volumeMounts:
- name: logs
mountPath: /var/log/appJSON Patches
For more precise changes:
patches:
- target:
kind: Deployment
name: order-api
patch: |
- op: replace
path: /spec/replicas
value: 10
- op: add
path: /spec/template/metadata/annotations/prometheus.io~1scrape
value: "true"Common Labels and Annotations
# kustomization.yaml
commonLabels:
app.kubernetes.io/part-of: ecommerce
app.kubernetes.io/managed-by: kustomize
environment: production
commonAnnotations:
team: commerceApplied to all resources in the kustomization.
Kustomize vs Helm
| Feature | Kustomize | Helm |
|---|---|---|
| Config approach | Overlay/patch | Template |
| Language | YAML | Go templates |
| Learning curve | Low | Medium |
| Package registry | No | Helm repos |
| Dependency management | No | Chart dependencies |
| Built into kubectl | Yes (-k) | Separate CLI |
| Conditionals | No | Yes |
| Loops | No | Yes |
Use Kustomize for environment-specific overlays on your own manifests. Use Helm for distributing reusable packages and when you need conditionals/loops. Many teams use both: Helm for third-party charts, Kustomize for their own applications.
---
Ready to go deeper? Master Kubernetes configuration with hands-on courses at CopyPasteLearn.
Ready to learn by doing?
Stop reading tutorials ā start building. Expert video courses with hands-on labs in real sandboxed environments.
Related Articles
YAML Syntax Guide for DevOps
Master YAML syntax for DevOps tools. Scalars, lists, maps, anchors, multi-line strings, and common gotchas with pipeline examples.
Flux GitOps Toolkit Deep Dive
Flux v2 uses GitOps Toolkit controllers for source management, Kustomize, Helm, and notifications. Learn how to structure a Flux GitOps repository.
YAML for DevOps Engineers
Master YAML for DevOps configuration. Scalars, lists, maps, anchors, multi-line strings, and common pitfalls to avoid in pipelines.
Kyverno Kubernetes Policy Engine
Kyverno validates, mutates, and generates Kubernetes resources using YAML policies instead of Rego. Learn how to enforce security standards, set defaults.
Learn Ansible Free: Beginner Guide
Start learning Ansible for free with hands-on examples. Master playbooks, inventory, modules, and roles to automate infrastructure.
Linkerd Lightweight Service Mesh
Linkerd is the lightest Kubernetes service mesh with automatic mTLS, golden metrics, and zero-config retries. Learn how Linkerd compares to Istio and when its.
Explore topics
Browse more articles on the topics covered here.