Kustomize Practice Questions (Compressed)
Question 1 – Multi-Environment Base + Overlays with Patches
Task: Build a complete base application with dev/prod overlays using patches and ConfigMap generators. This is a dependent question—your solution here becomes the foundation for Q2 and Q3.
Steps:
Create base structure:
base/ deployment.yaml # API server: node:18-alpine, port 3000, 1 replica service.yaml # ClusterIP service on port 80→3000 configmap.yaml # APP_NAME, LOG_LEVEL, REDIS_HOST redis-deployment.yaml # Redis: redis:7-alpine, port 6379 redis-service.yaml # Redis ClusterIP service kustomization.yaml # resources: [all above]Create dev overlay with patches:
overlays/dev/ kustomization.yaml # resources: ../../base, namespace: dev, namePrefix: dev-, patches: [deployment-patch.yaml] patches/ deployment-patch.yaml # Patch replicas: 2Create prod overlay with patches + resource limits:
overlays/prod/ kustomization.yaml # resources: ../../base, namespace: prod, namePrefix: prod-, patches: [deployment-patch.yaml, resources-patch.yaml] patches/ deployment-patch.yaml # Patch replicas: 4 resources-patch.yaml # CPU: 100m→500m, Memory: 128Mi→512MiAdd labels to both overlays using
labelsfield (no deprecation warnings)Test:
bashkustomize build overlays/dev/ kustomize build overlays/prod/
Deliverables:
- ✅ Base with 5 resources (2 deployments, 2 services, 1 configmap)
- ✅ Dev overlay: 2 replicas, dev namespace, dev- prefix, labels applied
- ✅ Prod overlay: 4 replicas, prod namespace, prod- prefix, resource limits, labels applied
- ✅ Both build cleanly with no warnings
Question 2 – ConfigMap/Secret Generators + Image Patching (Dependent on Q1)
Task: Extend your Q1 solution to replace static ConfigMaps with generators and manage image tags per environment.
Steps:
Create environment config files:
overlays/dev/.env.config # APP_NAME=myapp-dev, LOG_LEVEL=debug, REDIS_HOST=redis-service overlays/prod/.env.config # APP_NAME=myapp-prod, LOG_LEVEL=info, REDIS_HOST=redis-serviceCreate secret files:
overlays/dev/.env.secrets # DB_PASSWORD=devpass123, DB_USER=dev overlays/prod/.env.secrets # DB_PASSWORD=prod-secure-xyz, DB_USER=prodUpdate overlays/dev/kustomization.yaml:
- Add
configMapGenerator:with.env.configfile - Add
secretGenerator:with.env.secretsfile - Add
images:section: changenodetag to18-alpine - Update deployment to reference generated ConfigMap name (with hash)
- Add
Update overlays/prod/kustomization.yaml:
- Same generators as dev (but different .env files)
images:changenodetag to18.20.0-alpine- Add
kustomizationflag to not add hash suffix (optional, for stable names)
Test:
bashkustomize build overlays/dev/ | grep ConfigMap kustomize build overlays/prod/ | grep ConfigMap kustomize build overlays/dev/ | grep image: kustomize build overlays/prod/ | grep image:
Deliverables:
- ✅ ConfigMaps generated from files (show hash suffix)
- ✅ Secrets generated from files
- ✅ Image tags differ: dev uses
18-alpine, prod uses18.20.0-alpine - ✅ Deployment references generated ConfigMap correctly
- ✅ Both build successfully
Question 3 – Advanced: Composable Multi-Base + JSON Patches (Independent)
Task: Build a separate advanced project that demonstrates multi-base composition, JSON patches (RFC 6902), and cross-cutting concerns (monitoring, security policies).
Steps:
Create separate project structure:
advanced/ bases/ core/ deployment.yaml # Generic stateless app (no image hardcoded) service.yaml kustomization.yaml monitoring/ servicemonitor.yaml (Prometheus) kustomization.yaml security/ networkpolicy.yaml podsecuritypolicy.yaml kustomization.yaml overlays/ staging/ kustomization.yaml # bases: [../../bases/core, ../../bases/monitoring], patches: [security-patch.json] prod/ kustomization.yaml # bases: [../../bases/core, ../../bases/monitoring, ../../bases/security]Create JSON patches for staging (RFC 6902):
- Add annotation
monitoring: "true"to all Pods - Add label
env: stagingto Deployments - Patch service type to
LoadBalancer(optional, for staging only)
- Add annotation
Use
patchesJson6902in overlays/staging/kustomization.yaml to apply JSON patchesProd overlay combines all bases directly (no JSON patches needed)
Test:
bashkustomize build overlays/staging/ | grep annotation kustomize build overlays/prod/ | grep NetworkPolicy
Deliverables:
- ✅ Multi-base composition working (core + monitoring + security)
- ✅ Staging applies JSON patches correctly
- ✅ Prod includes all security bases
- ✅ Both build without errors
- ✅ Clear separation of concerns: core app / monitoring / security
How to Approach:
- Q1 (Foundation): Build everything from scratch. Learn base → overlay → patches workflow.
- Q2 (Extend Q1): Use your Q1 solution as base. Add generators and image management.
- Q3 (Standalone Deep Dive): Start fresh. Focus on advanced patterns: multi-base, JSON patches, composition.
Time estimate: Q1: 30min, Q2: 20min (extending Q1), Q3: 25min (independent exploration)