Nextgen Blog
HomeLearnAIQuantumRoboticsSecuritySpaceAbout
Nextgen Blog

By Anubhav โ€” full stack engineer, IIT Mandi CSE. Deep dives into AI, software engineering, and the technologies shaping the next generation of tech.

Navigate

  • Home
  • Learn
  • Blog
  • Archive
  • About

Topics

  • Artificial Intelligence
  • Quantum Computing
  • Robotics
  • Cybersecurity
  • Space Tech

Connect

Built with โค๏ธ & By - Anubhav

ยฉ 2026 Nextgen Blog by Anubhav. All rights reserved.

Privacy PolicyTerms of Service
Phase 05 ยท Production & GitOpsChapter 27 of 33
26.
Phase 05Read time ~14 minDifficulty intermediate

Kustomize ๐Ÿงฉ

Warrior, now that you understand Helm, the next important Kubernetes configuration tool is Kustomize.

In this chapter
  • 01Why do we need Kustomize?
  • 02What exactly is Kustomize?
  • 03Kustomize is built into kubectl
  • 04Basic Kustomize architecture
  • 05What is a Base?
  • 06kustomization.yaml
  • 07Complete Base Example
  • 08deployment.yaml
  • 09service.yaml
  • 10kustomization.yaml
  • 11Create Development Overlay
  • 12Development kustomization.yaml
  • 13Development patch
  • 14Preview the final YAML
  • 15Apply Kustomize
  • 16Production Overlay
  • 17Kustomize image customization
  • 18Change image repository
  • 19ConfigMap generation
  • 20ConfigMap from file
  • 21Secret generation
  • 22Namespace customization
  • 23Common labels
  • 24Name Prefix
  • 25Patches
  • 26JSON 6902 patches
  • 27Strategic merge vs JSON patches
  • 28Strategic merge style
  • 29JSON 6902
  • 30Kustomize with Next.js + Node.js
  • 31Environment differences
  • 32Development
  • 33Staging
  • 34Production
  • 35Helm vs Kustomize
  • 36Helm
  • 37Kustomize
  • 38Side-by-side comparison
  • 39Helm mental model
  • 40Kustomize mental model
  • 41Can Helm and Kustomize work together?
  • 42When should you use Kustomize?
  • 43You already have normal Kubernetes YAML
  • 44You want minimal abstraction
  • 45You don't need a package manager
  • 46When is Helm useful?
  • 47Production Git structure
  • 48Kustomize in CI/CD
  • 49Very important: Kustomize doesn't deploy applications itself
  • 50Useful commands
  • 51Render
  • 52Apply
  • 53Delete
  • 54Preview differences
  • 55Practical exercise
  • 56Interview Questions
  • 57Q1. What is Kustomize?
  • 58Q2. Is Kustomize a replacement for Kubernetes?
  • 59Q3. What is a Kustomize base?
  • 60Q4. What is an overlay?
  • 61Q5. What does kubectl apply -k mean?
  • 62Q6. Helm vs Kustomize?
  • 63The biggest mental model
  • 64One sentence to remember:
  • 65Next Chapter โ†’ Chapter 27: Local Kubernetes ๐Ÿ–ฅ๏ธ
In this chapter (65 sections)
01Why do we need Kustomize?02What exactly is Kustomize?03Kustomize is built into kubectl04Basic Kustomize architecture05What is a Base?06kustomization.yaml07Complete Base Example08deployment.yaml09service.yaml10kustomization.yaml11Create Development Overlay12Development kustomization.yaml13Development patch14Preview the final YAML15Apply Kustomize16Production Overlay17Kustomize image customization18Change image repository19ConfigMap generation20ConfigMap from file21Secret generation22Namespace customization23Common labels24Name Prefix25Patches26JSON 6902 patches27Strategic merge vs JSON patches28Strategic merge style29JSON 690230Kustomize with Next.js + Node.js31Environment differences32Development33Staging34Production35Helm vs Kustomize36Helm37Kustomize38Side-by-side comparison39Helm mental model40Kustomize mental model41Can Helm and Kustomize work together?42When should you use Kustomize?43You already have normal Kubernetes YAML44You want minimal abstraction45You don't need a package manager46When is Helm useful?47Production Git structure48Kustomize in CI/CD49Very important: Kustomize doesn't deploy applications itself50Useful commands51Render52Apply53Delete54Preview differences55Practical exercise56Interview Questions57Q1. What is Kustomize?58Q2. Is Kustomize a replacement for Kubernetes?59Q3. What is a Kustomize base?60Q4. What is an overlay?61Q5. What does kubectl apply -k mean?62Q6. Helm vs Kustomize?63The biggest mental model64One sentence to remember:65Next Chapter โ†’ Chapter 27: Local Kubernetes ๐Ÿ–ฅ๏ธ

The key idea is very simple:

Kustomize lets you reuse normal Kubernetes YAML and customize it for different environments without creating completely separate YAML files.


1. Why do we need Kustomize?#

Imagine you have a Node.js application.

In development:

replicas: 1
image: node-api:dev

Staging:

replicas: 2
image: node-api:staging

Production:

replicas: 5
image: node-api:1.4.0

Most of the Kubernetes configuration is identical.

Without Kustomize, you might create:

deployment-dev.yaml
deployment-staging.yaml
deployment-prod.yaml

This causes duplication.

deployment-dev.yaml
        โ†“
deployment-staging.yaml
        โ†“
deployment-prod.yaml

Eventually someone changes one file but forgets another.

Kustomize solves this using:

                 Base
                  โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ†“       โ†“       โ†“
         Dev   Staging   Prod

2. What exactly is Kustomize?#

Kustomize is a Kubernetes-native configuration customization tool.

It allows you to define:

Base Kubernetes YAML
        +
Environment-specific changes
        โ†“
Final Kubernetes YAML

Unlike Helm, Kustomize does not primarily use templates.

Instead, it works with existing Kubernetes YAML and applies modifications/patches.


3. Kustomize is built into kubectl#

This is very important.

You don't necessarily need a separate CLI.

You can use:

kubectl apply -k .

Notice:

-f

means normal YAML:

kubectl apply -f deployment.yaml

while:

-k

means Kustomize:

kubectl apply -k .

Think:

kubectl apply -f
        โ†“
regular YAML
 
kubectl apply -k
        โ†“
Kustomize configuration

4. Basic Kustomize architecture#

A common structure is:

k8s/
โ”‚
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ deployment.yaml
โ”‚   โ”œโ”€โ”€ service.yaml
โ”‚   โ””โ”€โ”€ kustomization.yaml
โ”‚
โ””โ”€โ”€ overlays/
    โ”‚
    โ”œโ”€โ”€ dev/
    โ”‚   โ”œโ”€โ”€ kustomization.yaml
    โ”‚   โ””โ”€โ”€ patch.yaml
    โ”‚
    โ”œโ”€โ”€ staging/
    โ”‚   โ”œโ”€โ”€ kustomization.yaml
    โ”‚   โ””โ”€โ”€ patch.yaml
    โ”‚
    โ””โ”€โ”€ production/
        โ”œโ”€โ”€ kustomization.yaml
        โ””โ”€โ”€ patch.yaml

Mental model:

                    BASE
                     โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ†“          โ†“          โ†“
        DEV       STAGING      PROD
          โ”‚          โ”‚           โ”‚
          โ†“          โ†“           โ†“
       customized customized  customized
       Kubernetes  Kubernetes  Kubernetes
       resources   resources   resources

5. What is a Base?#

A base contains configuration common to all environments.

For example:

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: node-api
 
spec:
  replicas: 2
 
  selector:
    matchLabels:
      app: node-api
 
  template:
    metadata:
      labels:
        app: node-api
 
    spec:
      containers:
        - name: node-api
          image: myregistry/node-api:latest
          ports:
            - containerPort: 3000

This is our base.


6. kustomization.yaml#

Kustomize needs a file called:

kustomization.yaml

Example:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
 
resources:
  - deployment.yaml
  - service.yaml

This tells Kustomize:

"These Kubernetes resources belong together."


7. Complete Base Example#

Let's build a Node.js API.

Directory:

k8s/
 
โ””โ”€โ”€ base/
    โ”œโ”€โ”€ deployment.yaml
    โ”œโ”€โ”€ service.yaml
    โ””โ”€โ”€ kustomization.yaml

deployment.yaml#

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: node-api
 
spec:
  replicas: 2
 
  selector:
    matchLabels:
      app: node-api
 
  template:
    metadata:
      labels:
        app: node-api
 
    spec:
      containers:
        - name: node-api
          image: myregistry/node-api:1.0.0
 
          ports:
            - containerPort: 3000
 
          resources:
            requests:
              cpu: "250m"
              memory: "256Mi"
 
            limits:
              cpu: "500m"
              memory: "512Mi"

service.yaml#

apiVersion: v1
kind: Service
 
metadata:
  name: node-api
 
spec:
  selector:
    app: node-api
 
  ports:
    - port: 80
      targetPort: 3000

kustomization.yaml#

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
 
resources:
  - deployment.yaml
  - service.yaml

Now we have our base.


8. Create Development Overlay#

Directory:

k8s/
โ”‚
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ deployment.yaml
โ”‚   โ”œโ”€โ”€ service.yaml
โ”‚   โ””โ”€โ”€ kustomization.yaml
โ”‚
โ””โ”€โ”€ overlays/
    โ””โ”€โ”€ dev/
        โ”œโ”€โ”€ kustomization.yaml
        โ””โ”€โ”€ patch.yaml

We want development to have:

replicas = 1
image = node-api:dev

We don't want to duplicate the entire Deployment.

Instead, we patch it.


9. Development kustomization.yaml#

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
 
resources:
  - ../../base
 
patches:
  - path: patch.yaml

Notice:

resources:
  - ../../base

We're saying:

Use the base configuration.

Then:

patches:
  - path: patch.yaml

means:

Apply these changes on top of the base.


10. Development patch#

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: node-api
 
spec:
  replicas: 1
 
  template:
    spec:
      containers:
        - name: node-api
          image: myregistry/node-api:dev

The final result becomes approximately:

Deployment:
  name: node-api
 
  replicas: 1
 
  image: myregistry/node-api:dev
 
  resources:
    requests:
      cpu: 250m
      memory: 256Mi

The resources from the base remain.

Only the required values changed.


11. Preview the final YAML#

This is one of the most useful commands:

kubectl kustomize overlays/dev

It doesn't deploy anything.

It generates the final Kubernetes YAML.

Think:

Base
 +
Patch
 โ†“
kubectl kustomize
 โ†“
Final YAML

You can inspect it before deployment.


12. Apply Kustomize#

Development:

kubectl apply -k overlays/dev

Staging:

kubectl apply -k overlays/staging

Production:

kubectl apply -k overlays/production

This is extremely convenient for CI/CD.


13. Production Overlay#

Our structure:

k8s/
โ”‚
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ deployment.yaml
โ”‚   โ”œโ”€โ”€ service.yaml
โ”‚   โ””โ”€โ”€ kustomization.yaml
โ”‚
โ””โ”€โ”€ overlays/
    โ”œโ”€โ”€ dev/
    โ”‚   โ”œโ”€โ”€ kustomization.yaml
    โ”‚   โ””โ”€โ”€ patch.yaml
    โ”‚
    โ”œโ”€โ”€ staging/
    โ”‚   โ”œโ”€โ”€ kustomization.yaml
    โ”‚   โ””โ”€โ”€ patch.yaml
    โ”‚
    โ””โ”€โ”€ production/
        โ”œโ”€โ”€ kustomization.yaml
        โ””โ”€โ”€ patch.yaml

Production kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
 
resources:
  - ../../base
 
patches:
  - path: patch.yaml

Production patch:

apiVersion: apps/v1
kind: Deployment
 
metadata:
  name: node-api
 
spec:
  replicas: 5
 
  template:
    spec:
      containers:
        - name: node-api
          image: myregistry/node-api:1.4.0

So:

BASE
 
replicas: 2
image: node-api:1.0.0
 
          โ†“
 
PRODUCTION OVERLAY
 
replicas: 5
image: node-api:1.4.0

14. Kustomize image customization#

Kustomize provides a convenient images field.

Instead of patching the image:

images:
  - name: myregistry/node-api
    newTag: "1.4.0"

Example:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
 
resources:
  - ../../base
 
images:
  - name: myregistry/node-api
    newTag: "1.4.0"

Base:

image: myregistry/node-api:1.0.0

Final:

image: myregistry/node-api:1.4.0

This is very useful in CI/CD.


15. Change image repository#

You can also change the repository:

images:
  - name: myregistry/node-api
    newName: 123456789.dkr.ecr.ap-south-1.amazonaws.com/node-api
    newTag: "1.4.0"

So development could use:

myregistry/node-api

while production uses:

AWS ECR

16. ConfigMap generation#

Kustomize can generate ConfigMaps.

Example:

configMapGenerator:
  - name: node-api-config
    literals:
      - NODE_ENV=production
      - LOG_LEVEL=info
      - PORT=3000

Complete:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
 
resources:
  - ../../base
 
configMapGenerator:
  - name: node-api-config
    literals:
      - NODE_ENV=production
      - LOG_LEVEL=info
      - PORT=3000

Kustomize generates a ConfigMap.

An important feature is that generated ConfigMaps can receive a content-based suffix/hash, which helps trigger Pod rollouts when configuration changes.

For example, conceptually:

node-api-config-8g7f6g

instead of simply:

node-api-config

This helps prevent stale configuration when referenced appropriately.


17. ConfigMap from file#

Suppose:

app.env

contains:

NODE_ENV=production
LOG_LEVEL=info
PORT=3000

You can use:

configMapGenerator:
  - name: node-api-config
    envs:
      - app.env

Kustomize generates the ConfigMap.


18. Secret generation#

Kustomize can also generate Secrets.

For example:

secretGenerator:
  - name: database-secret
    literals:
      - DB_USER=admin
      - DB_PASSWORD=supersecret

However:

โš ๏ธ Don't put real production secrets directly into Git just because Kustomize supports secretGenerator.

Remember:

Base64 โ‰  encryption

For production, consider:

AWS Secrets Manager
GCP Secret Manager
Azure Key Vault
Vault
External Secrets Operator

19. Namespace customization#

You can specify a namespace:

namespace: development

For example:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
 
namespace: development
 
resources:
  - ../../base

Kustomize will apply the namespace to namespace-scoped resources.


20. Common labels#

You can add common labels:

commonLabels:
  team: platform
  environment: production

Depending on your Kustomize version/features, newer recommended fields may include labels; the exact transformation behavior should be tested with your manifests.

Example concept:

Deployment
Service
ConfigMap

all receive:

environment=production

This is useful for:

  • filtering
  • monitoring
  • organization
  • cost allocation
  • debugging

21. Name Prefix#

Kustomize can modify resource names.

namePrefix: prod-

If base contains:

metadata:
  name: node-api

the generated name becomes:

prod-node-api

Similarly:

nameSuffix: -v1

could produce:

node-api-v1

Be careful with names because references between resources must remain correctly transformed.


22. Patches#

One of the most important Kustomize concepts is patching.

Suppose base has:

replicas: 2

Production needs:

replicas: 5

Instead of copying the Deployment:

replicas: 5

you patch the existing resource.

Think:

Original YAML
      โ†“
      + Patch
      โ†“
Modified YAML

23. JSON 6902 patches#

Kustomize also supports JSON 6902 patches.

Example:

patches:
  - target:
      group: apps
      version: v1
      kind: Deployment
      name: node-api
 
    patch: |-
      - op: replace
        path: /spec/replicas
        value: 5

This explicitly says:

Find Deployment/node-api
 
Replace:
/spec/replicas
 
With:
5

This is powerful for precise changes.


24. Strategic merge vs JSON patches#

You'll encounter different patch mechanisms.

Strategic merge style#

Easy for common Kubernetes resource modifications.

Example:

spec:
  replicas: 5

JSON 6902#

More explicit:

- op: replace
  path: /spec/replicas
  value: 5

Think:

Strategic/structured patch
        โ†“
"Change this Kubernetes field"
 
JSON 6902
        โ†“
"Perform this exact operation at this exact path"

For many modern Kustomize configurations, the unified patches field can be used for both styles.


25. Kustomize with Next.js + Node.js#

Let's make this realistic.

Imagine your architecture:

                   Internet
                      โ”‚
                      โ†“
                  Ingress
                      โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ†“               โ†“
        Next.js Service   Node.js Service
              โ†“               โ†“
          Next.js Pods     Node Pods
                              โ”‚
                       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
                       โ†“             โ†“
                    Redis        PostgreSQL

You could maintain:

k8s/
โ”‚
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ frontend-deployment.yaml
โ”‚   โ”œโ”€โ”€ frontend-service.yaml
โ”‚   โ”œโ”€โ”€ backend-deployment.yaml
โ”‚   โ”œโ”€โ”€ backend-service.yaml
โ”‚   โ”œโ”€โ”€ ingress.yaml
โ”‚   โ””โ”€โ”€ kustomization.yaml
โ”‚
โ””โ”€โ”€ overlays/
    โ”œโ”€โ”€ dev/
    โ”œโ”€โ”€ staging/
    โ””โ”€โ”€ production/

The base contains architecture.

The overlays contain environment differences.


26. Environment differences#

For example:

Development#

Frontend replicas: 1
Backend replicas: 1
 
Backend image:
node-api:dev
 
Database:
development DB
 
Log level:
debug

Staging#

Frontend replicas: 2
Backend replicas: 2
 
Backend image:
node-api:staging
 
Log level:
info

Production#

Frontend replicas: 5
Backend replicas: 5
 
Backend image:
node-api:1.4.0
 
Log level:
warn
 
Resources:
higher

Notice something important:

The architecture remains the same.

Only configuration changes.


27. Helm vs Kustomize#

This is a very common interview question.

Helm#

Templates
+
values.yaml
+
Helm engine
โ†“
Kubernetes YAML

Example:

replicas: {{ .Values.replicaCount }}

Values:

replicaCount: 5

Kustomize#

Base YAML
+
Overlay/Patches
โ†“
Kubernetes YAML

No traditional template language is required.


28. Side-by-side comparison#

Feature Helm Kustomize
Templates Yes No traditional templates
Values Yes Overlays/patches
Packaging Strong Not its primary goal
Releases Yes No Helm-style release
Rollbacks Helm release history Usually Git/Kubernetes rollout mechanisms
Kubernetes-native External tool Integrated with kubectl
Reuse Templates Bases/overlays
Complexity Can become template-heavy Often straightforward
Dependencies Strong chart dependency system More composition-oriented
Good for Reusable packages/platforms Environment customization

29. Helm mental model#

Remember:

Chart
 โ”‚
 โ”œโ”€โ”€ templates/
 โ””โ”€โ”€ values.yaml
        โ”‚
        โ†“
      Helm
        โ”‚
        โ†“
Rendered Kubernetes YAML

30. Kustomize mental model#

Base YAML
    โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ†“             โ†“
  Dev patch    Prod patch
    โ”‚             โ”‚
    โ†“             โ†“
 Dev YAML      Prod YAML

This distinction is extremely important.


31. Can Helm and Kustomize work together?#

Yes.

You don't necessarily have to choose only one.

For example:

Helm
 โ†“
Generate Kubernetes resources
 โ†“
Kustomize
 โ†“
Environment-specific customization

There are multiple possible architectures, but don't add both just because you can.

More tools can mean more complexity.


32. When should you use Kustomize?#

Kustomize is particularly attractive when:

You already have normal Kubernetes YAML#

deployment.yaml
service.yaml
ingress.yaml

and simply need:

dev
staging
production

customizations.


You want minimal abstraction#

Your YAML remains recognizable Kubernetes YAML.


You don't need a package manager#

If you're not distributing a reusable application package, Helm's packaging/release features may be unnecessary.


33. When is Helm useful?#

Helm is particularly useful when:

You want to package an application

or:

You want configurable reusable charts

or:

You want to install third-party Kubernetes applications

Examples include charts for common infrastructure components.


34. Production Git structure#

A realistic Git repository might look like:

my-platform/
โ”‚
โ”œโ”€โ”€ application/
โ”‚   โ”œโ”€โ”€ frontend/
โ”‚   โ””โ”€โ”€ backend/
โ”‚
โ”œโ”€โ”€ docker/
โ”‚
โ””โ”€โ”€ k8s/
    โ”‚
    โ”œโ”€โ”€ base/
    โ”‚   โ”œโ”€โ”€ frontend/
    โ”‚   โ”œโ”€โ”€ backend/
    โ”‚   โ”œโ”€โ”€ redis/
    โ”‚   โ””โ”€โ”€ ingress/
    โ”‚
    โ””โ”€โ”€ overlays/
        โ”‚
        โ”œโ”€โ”€ dev/
        โ”‚
        โ”œโ”€โ”€ staging/
        โ”‚
        โ””โ”€โ”€ production/

Then CI/CD can do:

kubectl apply -k k8s/overlays/production

or render it first:

kubectl kustomize k8s/overlays/production

35. Kustomize in CI/CD#

Suppose GitHub Actions builds:

node-api:1.5.0

Then CI updates:

images:
  - name: myregistry/node-api
    newTag: "1.5.0"

Then deployment:

kubectl apply -k k8s/overlays/production

Flow:

Developer
    โ”‚
    โ†“
Git Push
    โ”‚
    โ†“
CI
    โ”‚
    โ”œโ”€โ”€ Test
    โ”œโ”€โ”€ Build
    โ”œโ”€โ”€ Docker Image
    โ””โ”€โ”€ Push Registry
            โ”‚
            โ†“
      node-api:1.5.0
            โ”‚
            โ†“
       Kustomize
            โ”‚
            โ†“
   Production manifests
            โ”‚
            โ†“
       Kubernetes
            โ”‚
            โ†“
       Deployment
            โ”‚
            โ†“
       Rolling Update

Now you're connecting the concepts you've already learned.


36. Very important: Kustomize doesn't deploy applications itself#

Kustomize's primary job is:

Generate/customize Kubernetes manifests

Kubernetes does the actual deployment.

For example:

kubectl kustomize overlays/prod

just renders YAML.

Whereas:

kubectl apply -k overlays/prod

renders and applies it through Kubernetes.


37. Useful commands#

Render#

kubectl kustomize overlays/dev

Apply#

kubectl apply -k overlays/dev

Delete#

kubectl delete -k overlays/dev

Preview differences#

kubectl diff -k overlays/dev

This is extremely useful before applying changes.


38. Practical exercise#

Create:

k8s/
โ”‚
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ deployment.yaml
โ”‚   โ”œโ”€โ”€ service.yaml
โ”‚   โ””โ”€โ”€ kustomization.yaml
โ”‚
โ””โ”€โ”€ overlays/
    โ”œโ”€โ”€ dev/
    โ”‚   โ”œโ”€โ”€ kustomization.yaml
    โ”‚   โ””โ”€โ”€ patch.yaml
    โ”‚
    โ””โ”€โ”€ production/
        โ”œโ”€โ”€ kustomization.yaml
        โ””โ”€โ”€ patch.yaml

Base:

replicas = 2
image = node-api:1.0.0

Dev:

replicas = 1
image = node-api:dev

Production:

replicas = 5
image = node-api:1.0.0

Then test:

kubectl kustomize overlays/dev

and:

kubectl kustomize overlays/production

Compare the output.


39. Interview Questions#

Q1. What is Kustomize?#

Kustomize is a Kubernetes configuration customization tool that lets us maintain reusable base manifests and environment-specific overlays without relying on traditional templates.


Q2. Is Kustomize a replacement for Kubernetes?#

No.

Kustomize โ†’ prepares/customizes manifests
 
Kubernetes โ†’ runs/manages workloads

Q3. What is a Kustomize base?#

A base contains common Kubernetes resources shared across environments.


Q4. What is an overlay?#

An overlay customizes a base for a particular environment or use case.

Example:

base
 โ†“
production overlay

Q5. What does kubectl apply -k mean?#

It tells kubectl to process a Kustomize directory and apply the generated resources.


Q6. Helm vs Kustomize?#

A strong interview answer:

Helm is a templating and package/release-management tool for Kubernetes, while Kustomize customizes existing Kubernetes manifests using bases, overlays, and patches. Helm is particularly useful for reusable packages and configurable charts, while Kustomize is useful when you want to keep native YAML and apply environment-specific changes.


40. The biggest mental model#

You've now learned:

                     Kubernetes
                         โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ†“                 โ†“                 โ†“
    Workloads         Networking        Config
       โ”‚                 โ”‚                 โ”‚
 Deployment          Service          ConfigMap
    Pod              Ingress            Secret
       โ”‚
       โ†“
   Scaling
       โ”‚
   HPA / CA

And now:

                 Kubernetes YAML
                       โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ†“                 โ†“
             Helm          Kustomize
              โ”‚                 โ”‚
        Templates +       Base + Overlays
          Values              + Patches
              โ”‚                 โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ†“
                Kubernetes API
                       โ†“
                    Cluster

๐Ÿง  Chapter 26 Cheat Sheet#

Kustomize
   โ†“
Customize Kubernetes YAML
 
Base
   โ†“
Common configuration
 
Overlay
   โ†“
Environment-specific configuration
 
kustomization.yaml
   โ†“
Defines resources/customizations
 
kubectl kustomize
   โ†“
Render manifests
 
kubectl apply -k
   โ†“
Apply Kustomize configuration
 
kubectl diff -k
   โ†“
Preview changes
 
Helm
   โ†“
Templates + values + packages/releases
 
Kustomize
   โ†“
Base + overlays + patches

One sentence to remember:#

Helm generates Kubernetes configuration from templates; Kustomize modifies existing Kubernetes configuration using bases and overlays.


Next Chapter โ†’ Chapter 27: Local Kubernetes ๐Ÿ–ฅ๏ธ#

We'll move from theory into actually running Kubernetes on your PC.

We'll cover:

  • Docker Desktop Kubernetes
  • Minikube
  • Kind
  • Which one you should use
  • Installing kubectl
  • Creating your first cluster
  • Creating your first Pod
  • Creating a Deployment
  • Creating a Service
  • Accessing your application from your browser
  • Kubernetes Dashboard options
  • Inspecting nodes and Pods
  • A complete local Node.js deployment
  • Your first real Kubernetes project ๐Ÿš€

Finished this chapter?

Mark it as complete to track your mastery.

Previous ChapterChapter 25 โ€” Helm โ›ตNext ChapterChapter 27 โ€” Local Kubernetes ๐Ÿ–ฅ๏ธ
PrevNext