Interview › Infrastructure as Code (Terraform, Ansible)
What is a kustomization.yaml, and what does it define?
Infrastructure as Code (Terraform, Ansible) · Advanced level
Answer
kustomization.yaml is the control file for Kustomize. It declares resources, bases, patches, generators, images, namespaces, labels, annotations, prefixes, suffixes, and other transformations that produce the final Kubernetes manifests.
Technical explanation
The file is declarative and represents the build recipe for final manifests.
It can pull resources from local paths or remote bases depending on policy.
Keep kustomization.yaml small by placing common YAML in resources and overlays.
Keep source manifests or IaC definitions readable enough that reviewers can understand the final desired state.
Use overlays, modules, or roles for reuse, but keep environment-specific differences explicit and reviewable.
Validate generated output in CI before applying it through kubectl, Argo CD, Terraform, or Ansible.
Hands-on example
1. Create a Kustomize base and overlay for: What is a kustomization.yaml, and what does it define?
2. Base files:
base/deployment.yaml
base/service.yaml
base/kustomization.yaml
base/kustomization.yaml:
resources:
- deployment.yaml
- service.yaml
commonLabels:
app.kubernetes.io/name: payments3. prod overlay:
resources:
-../../base
namePrefix: prod-
namespace: payments-prod
images:
- name: ghcr.io/company/payments
newTag: 1.8.4
configMapGenerator:
- name: app-config
literals:
- LOG_LEVEL=info
patches:
- path: replica-patch.yaml4. Render and apply:
kubectl kustomize overlays/prod
kubectl diff -k overlays/prod
kubectl apply -k overlays/prod5. In GitOps, point Argo CD at overlays/prod and let it render, compare, and sync the desired state.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Infrastructure as Code (Terraform, Ansible) interview questions
- What is Kustomize, and how does it differ from Helm?
- What is the difference between a base and an overlay in Kustomize?
- Can Terraform and Ansible be used together, and how would you combine them?
- How do overlays customise a base without copying it?
- When would you choose Ansible over Terraform and vice versa?
- What are strategic merge patches versus JSON 6902 patches in Kustomize?
- What is ansible-lint, and what does it catch?
- How does Kustomize handle environment-specific configuration?