# Deploy devkubectl apply -k myapp/overlays/dev/
# Deploy production to a separate namespacekubectl create namespace production
kubectl apply -k myapp/overlays/production/ -n production
# Verifykubectl get all -l environment=dev
kubectl get all -n production -l environment=production
# Clean upkubectl delete -k myapp/overlays/dev/
kubectl delete -k myapp/overlays/production/ -n production
kubectl delete namespace production
Key Takeaways
What you learned:
✅ Base + Overlays pattern: Common config in base, environment-specific in overlays
✅ Transformers: namePrefix, commonLabels, replicas, images
✅ Patches: Strategic merge patches for targeted modifications
✅ Generators: ConfigMaps with automatic hash suffixes
✅ No templates: Pure YAML manipulation, easy to understand
Kustomize workflow:
1. Create base with common resources
2. Create overlays for each environment
3. Use transformers for simple changes
4. Use patches for complex modifications
5. Build with: kubectl kustomize <overlay-path>/
6. Apply with: kubectl apply -k <overlay-path>/
When to use what:
Need
Use
Add prefix/suffix
namePrefix/nameSuffix
Add labels to all
commonLabels
Change replicas
replicas field
Update image tag
images field
Generate ConfigMap
configMapGenerator
Modify specific fields
patches
Quick Reference
# Build kustomizationkubectl kustomize <directory>
# Apply kustomizationkubectl apply -k <directory>
# Delete kustomizationkubectl delete -k <directory>
# Validate (dry-run)kubectl apply -k <directory> --dry-run=client
# See only specific resourcekubectl kustomize <directory> | grep -A 20"kind: Deployment"