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 03 · Networking & ScalingChapter 17 of 33
16.
Phase 03Read time ~15 minDifficulty intermediate

Cluster Autoscaler

Warrior, in Chapter 15 we learned HPA, which scales Pods.

In this chapter
  • 01The Problem
  • 02Cluster Autoscaler Solves This
  • 03HPA vs Cluster Autoscaler
  • 04Why Not Just Have 100 Nodes?
  • 05Kubernetes Scheduling Comes First
  • 06Why Does a Pod Become Pending?
  • 07Resource Requests Matter Again
  • 08Cluster Autoscaler Doesn't Look Only at CPU Usage
  • 09Node Autoscaling
  • 10Node Pools
  • 11Example Node Pools
  • 12API workloads
  • 13AI workloads
  • 14Cloud Architecture
  • 15EKS Example
  • 16GKE Example
  • 17AKS Example
  • 18Minimum and Maximum Nodes
  • 19Scale Up
  • 20Scale Down
  • 21Node Drain
  • 22PodDisruptionBudget
  • 23Why PDB Matters for Autoscaling
  • 24Cluster Autoscaler vs PDB
  • 25What Happens If Maximum Nodes Is Reached?
  • 26HPA + Cluster Autoscaler Combined
  • 27Step 1
  • 28Step 2
  • 29Step 3
  • 30Step 4
  • 31Step 5
  • 32Step 6
  • 33Step 7
  • 34Step 8
  • 35A Very Important Difference
  • 36Why Bad Requests Cause Problems
  • 37Too-Low Requests
  • 38AI/LLM Example
  • 39Node Selectors and Node Pools
  • 40Cluster Autoscaler Is Not HPA
  • 41HPA asks:
  • 42Cluster Autoscaler asks:
  • 43Common Troubleshooting Scenario
  • 44Debugging Flow
  • 45What If the Problem Is a PVC?
  • 46Production Architecture
  • 47Important Interview Questions
  • 48Q1. What is Cluster Autoscaler?
  • 49Q2. HPA vs Cluster Autoscaler?
  • 50Q3. When does Cluster Autoscaler usually scale up?
  • 51Q4. Does Cluster Autoscaler directly create Pods?
  • 52Q5. Does HPA create nodes?
  • 53Q6. What happens if max node count is reached?
  • 54Q7. Why is kubectl describe pod important?
  • 55Q8. What is a node pool?
  • 56Q9. What is a PodDisruptionBudget?
  • 57Q10. Does Cluster Autoscaler scale based simply on CPU percentage?
  • 58Next → Chapter 17: Kubernetes Scheduling
In this chapter (58 sections)
01The Problem02Cluster Autoscaler Solves This03HPA vs Cluster Autoscaler04Why Not Just Have 100 Nodes?05Kubernetes Scheduling Comes First06Why Does a Pod Become Pending?07Resource Requests Matter Again08Cluster Autoscaler Doesn't Look Only at CPU Usage09Node Autoscaling10Node Pools11Example Node Pools12API workloads13AI workloads14Cloud Architecture15EKS Example16GKE Example17AKS Example18Minimum and Maximum Nodes19Scale Up20Scale Down21Node Drain22PodDisruptionBudget23Why PDB Matters for Autoscaling24Cluster Autoscaler vs PDB25What Happens If Maximum Nodes Is Reached?26HPA + Cluster Autoscaler Combined27Step 128Step 229Step 330Step 431Step 532Step 633Step 734Step 835A Very Important Difference36Why Bad Requests Cause Problems37Too-Low Requests38AI/LLM Example39Node Selectors and Node Pools40Cluster Autoscaler Is Not HPA41HPA asks:42Cluster Autoscaler asks:43Common Troubleshooting Scenario44Debugging Flow45What If the Problem Is a PVC?46Production Architecture47Important Interview Questions48Q1. What is Cluster Autoscaler?49Q2. HPA vs Cluster Autoscaler?50Q3. When does Cluster Autoscaler usually scale up?51Q4. Does Cluster Autoscaler directly create Pods?52Q5. Does HPA create nodes?53Q6. What happens if max node count is reached?54Q7. Why is kubectl describe pod important?55Q8. What is a node pool?56Q9. What is a PodDisruptionBudget?57Q10. Does Cluster Autoscaler scale based simply on CPU percentage?58Next → Chapter 17: Kubernetes Scheduling

Now we solve the next problem:

What happens when Kubernetes wants more Pods, but the existing worker nodes don't have enough capacity?

That's where Cluster Autoscaler (CA) comes in.


1. The Problem#

Suppose your cluster has:

Node 1
CPU: 4 cores
Memory: 16 GB
 
Node 2
CPU: 4 cores
Memory: 16 GB

Your application currently has:

3 Pods

Traffic increases.

HPA says:

3 Pods
   ↓
8 Pods

But the existing nodes can only fit 5 Pods.

Now you have:

Pod 1   Running
Pod 2   Running
Pod 3   Running
Pod 4   Running
Pod 5   Running
Pod 6   Pending
Pod 7   Pending
Pod 8   Pending

Why?

Because there isn't enough node capacity.


2. Cluster Autoscaler Solves This#

Cluster Autoscaler can detect that Pods cannot be scheduled because the cluster lacks capacity.

It can then request additional nodes from the underlying infrastructure.

HPA
 │
 │ increases Pods
 ▼
8 Pods
 │
 │ insufficient capacity
 ▼
Pending Pods
 │
 ▼
Cluster Autoscaler
 │
 │ adds node
 ▼
New Worker Node
 │
 ▼
Scheduler
 │
 ▼
Pending Pods → Running

3. HPA vs Cluster Autoscaler#

This is one of the most important Kubernetes interview concepts.

Component Scales Example
HPA Pods 3 → 8 Pods
Cluster Autoscaler Nodes 2 → 3 Nodes

Think:

HPA
= application capacity
 
Cluster Autoscaler
= infrastructure capacity

4. Why Not Just Have 100 Nodes?#

You could, but that would waste resources.

Imagine:

Normal traffic:
 
2 Nodes needed

but you permanently run:

20 Nodes

You may pay for resources you aren't using.

Autoscaling allows:

Low traffic
    ↓
2 Nodes
 
High traffic
    ↓
10 Nodes
 
Traffic decreases
    ↓
3 Nodes

So the cluster can adapt to demand.


5. Kubernetes Scheduling Comes First#

Remember Chapter 17 is coming later, but we already know the basic scheduler concept.

The flow is:

Pod created
     ↓
Scheduler looks for suitable node
     ↓
Node has enough capacity?
     │
   ┌─┴─┐
  YES  NO
   │    │
   ▼    ▼
Run   Pending
       │
       ▼
Cluster Autoscaler

Cluster Autoscaler doesn't replace the scheduler.

It reacts to situations where scheduling cannot happen because more node capacity is needed.


6. Why Does a Pod Become Pending?#

Suppose your Pod requests:

resources:
  requests:
    cpu: "1"
    memory: "2Gi"

But every node has insufficient allocatable resources.

The Pod may remain:

Pending

Check:

kubectl get pods

Then:

kubectl describe pod <pod-name>

You may see an event similar to:

0/3 nodes are available:
Insufficient cpu

or:

Insufficient memory

This is an important signal.


7. Resource Requests Matter Again#

Suppose a node has:

8 CPU

You might think:

8 Pods × 1 CPU = 8 CPU

But Kubernetes schedules based primarily on requested resources, along with other constraints and allocatable capacity.

For example:

resources:
  requests:
    cpu: "2"

If a node only has:

1.5 CPU allocatable

the Pod cannot fit there, even if current observed CPU usage looks low.

This is why correctly configuring requests is important.


8. Cluster Autoscaler Doesn't Look Only at CPU Usage#

This is a common beginner misconception.

Cluster Autoscaler isn't simply:

CPU > 80%
→ create node

Its core concern is whether Pods are unschedulable and whether adding/removing nodes would improve scheduling.

Example:

Node CPU usage = 60%
 
But:
 
Pod requires 4 CPU
Node has only 3 CPU allocatable

The Pod may still be unschedulable.

So:

Observed utilization and schedulability are different concepts.


9. Node Autoscaling#

Imagine:

Before:
 
┌──────────┐
│ Node 1   │
│ 4 CPU    │
└──────────┘
 
┌──────────┐
│ Node 2   │
│ 4 CPU    │
└──────────┘

HPA creates additional Pods.

Capacity is insufficient.

Cluster Autoscaler:

          Cluster Autoscaler
                  │
                  ▼
            Add Node 3
                  │
                  ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Node 1   │ │ Node 2   │ │ Node 3   │
└──────────┘ └──────────┘ └──────────┘

Scheduler then places Pods on Node 3.


10. Node Pools#

In cloud Kubernetes, nodes are commonly grouped into node pools or node groups.

For example:

Cluster
│
├── General Node Pool
│   ├── Node 1
│   ├── Node 2
│   └── Node 3
│
└── GPU Node Pool
    ├── GPU Node 1
    └── GPU Node 2

Different workloads can use different node types.


11. Example Node Pools#

Imagine your company runs:

API workloads#

CPU: 4
Memory: 16 GB

AI workloads#

GPU
CPU: 16
Memory: 64 GB

You might have:

Node Pool A
────────────────
General workloads
CPU optimized
 
Node Pool B
────────────────
AI workloads
GPU nodes

This is especially relevant for AI/LLM infrastructure.


12. Cloud Architecture#

In a cloud environment, Kubernetes doesn't necessarily manufacture a physical machine itself.

The architecture is more like:

Kubernetes
    │
    ▼
Node Autoscaling Component
    │
    ▼
Cloud Provider
    │
    ▼
VM / Compute Instance
    │
    ▼
Worker Node joins cluster

For example:

EKS → AWS infrastructure
GKE → Google Cloud infrastructure
AKS → Azure infrastructure

13. EKS Example#

Imagine an EKS cluster:

EKS Cluster
│
├── Node Group
│   ├── EC2 Node
│   └── EC2 Node

Suppose:

Minimum nodes = 2
Maximum nodes = 10

Traffic increases:

2 Nodes
 ↓
3 Nodes
 ↓
4 Nodes

Traffic decreases:

4 Nodes
 ↓
3 Nodes
 ↓
2 Nodes

The exact implementation depends on how the EKS node groups and autoscaling are configured.


14. GKE Example#

Google Kubernetes Engine:

GKE Cluster
│
└── Node Pool
      │
      ├── Node
      ├── Node
      └── Node

Autoscaling can adjust the node pool within configured boundaries.


15. AKS Example#

Azure Kubernetes Service:

AKS Cluster
│
└── Node Pool
      │
      ├── Node
      ├── Node
      └── Node

Node pool autoscaling adjusts capacity according to configured constraints and workload demand.


16. Minimum and Maximum Nodes#

A node autoscaling configuration commonly has:

Minimum nodes
Maximum nodes

For example:

min = 2
max = 10

Means:

Never intentionally go below 2
Never intentionally exceed 10

Conceptually:

Traffic ↓
   ↓
10 → 8 → 5 → 3 → 2
 
Traffic ↑
   ↓
2 → 3 → 5 → 8 → 10

17. Scale Up#

Let's understand scale-up carefully.

1. Traffic increases
        ↓
2. HPA increases replicas
        ↓
3. New Pods created
        ↓
4. Scheduler tries to place Pods
        ↓
5. No suitable node
        ↓
6. Pods become Pending
        ↓
7. Cluster Autoscaler detects unschedulable Pods
        ↓
8. Node capacity increases
        ↓
9. Scheduler places Pods
        ↓
10. Pods become Running

That's the complete chain.


18. Scale Down#

Now traffic decreases.

Traffic ↓
   ↓
HPA reduces Pods
   ↓
Some nodes become underutilized
   ↓
Cluster Autoscaler evaluates nodes
   ↓
Can Pods be moved elsewhere?
   ↓
Yes
   ↓
Node can be removed

The important question is:

Can the workloads on this node safely be moved elsewhere?

Autoscaling doesn't simply delete arbitrary nodes.


19. Node Drain#

Before removing a node, workloads may need to be moved.

Conceptually:

Node 3
│
├── Pod A
├── Pod B
└── Pod C

Node removal:

Pod A ──────→ Node 1
Pod B ──────→ Node 2
Pod C ──────→ Node 1

Then:

Node 3
   ↓
Removed

This is related to node draining and workload disruption.


20. PodDisruptionBudget#

Here's an important production concept.

Suppose:

5 replicas

You don't want maintenance or node removal to take down all 5 at once.

A PodDisruptionBudget (PDB) can limit certain forms of voluntary disruption.

Example:

apiVersion: policy/v1
kind: PodDisruptionBudget
 
metadata:
  name: node-api-pdb
 
spec:
  minAvailable: 3
 
  selector:
    matchLabels:
      app: node-api

This says:

Try to keep at least 3 matching Pods available during voluntary disruptions.


21. Why PDB Matters for Autoscaling#

Imagine:

5 Pods

and:

minAvailable: 3

Then Kubernetes should preserve the required availability during supported voluntary disruptions.

This helps protect applications while nodes are drained or maintained.

Important:

PDB is not a guarantee against every kind of failure.

It mainly governs voluntary disruptions.

A sudden node crash can still take Pods down.


22. Cluster Autoscaler vs PDB#

They solve different problems.

Cluster Autoscaler
        │
        ▼
How many nodes do I need?
 
PDB
        │
        ▼
How many Pods can voluntarily be disrupted?

Together they can support safer infrastructure scaling.


23. What Happens If Maximum Nodes Is Reached?#

Suppose:

maxNodes = 5

But demand requires:

8 nodes

Cluster Autoscaler cannot exceed its configured maximum.

You could end up with:

5 Nodes
   ↓
Not enough capacity
   ↓
Some Pods remain Pending

This is an important production failure scenario.


24. HPA + Cluster Autoscaler Combined#

Now let's combine everything from Chapters 13–16.

Imagine your Node.js API:

Deployment
replicas = 2

HPA:

min = 2
max = 10
CPU target = 70%

Node pool:

min nodes = 2
max nodes = 5

Traffic suddenly increases.

Step 1#

CPU increases:

CPU ↑

Step 2#

HPA reacts:

2 Pods
 ↓
5 Pods

Step 3#

More traffic:

5 Pods
 ↓
10 Pods

Step 4#

Nodes don't have enough capacity:

Some Pods → Pending

Step 5#

Cluster Autoscaler:

2 Nodes
 ↓
3 Nodes

Step 6#

Scheduler:

Pending Pods
      ↓
New Node

Step 7#

Pods become:

Running
Ready

Step 8#

Service routes traffic.

Complete:

                Traffic
                   │
                   ▼
                 HPA
                   │
             More Pods
                   │
                   ▼
            Scheduler
                   │
           insufficient?
             ┌─────┴─────┐
            No          Yes
            │             │
            ▼             ▼
          Run       Cluster Autoscaler
                          │
                          ▼
                      More Nodes
                          │
                          ▼
                       Scheduler
                          │
                          ▼
                         Pods

25. A Very Important Difference#

Don't confuse:

CPU utilization

with:

CPU capacity

Example:

Node:
8 CPU
 
Current usage:
4 CPU

You might think:

50% usage → plenty of space

But a new Pod requests:

6 CPU

It can't fit because only about 4 CPU remains, and Kubernetes scheduling considers requests and allocatable capacity, not simply current observed usage.

Therefore:

Autoscaling and scheduling are heavily influenced by resource requests.


26. Why Bad Requests Cause Problems#

Suppose you configure:

requests:
  cpu: "2"

for every tiny Node.js Pod.

Your application actually uses:

100m

You may have plenty of actual unused CPU.

But Kubernetes sees:

2 CPU requested

for each Pod.

So the scheduler may decide:

Not enough capacity

and Cluster Autoscaler might add nodes unnecessarily.

Therefore:

Overestimating requests can cause excessive infrastructure scaling.


27. Too-Low Requests#

The opposite is also dangerous.

Suppose:

requests:
  cpu: "50m"

but application normally needs:

500m

Kubernetes may pack many Pods onto the same node because their requests look tiny.

Later:

Traffic ↑
CPU ↑

and nodes may become heavily loaded.

So resource sizing should be based on actual workload measurements.


28. AI/LLM Example#

This is especially important for your AI projects.

Imagine:

LLM inference service

One GPU node:

GPU = 1

Your Pod requests:

resources:
  limits:
    nvidia.com/gpu: 1

If you need another inference replica:

Pod 1 → GPU Node 1
Pod 2 → Pending

because no available GPU exists.

Node autoscaling may need to provision another GPU-capable node, assuming your cluster/cloud setup supports that behavior.

Then:

GPU Node 1
   ↓
Inference Pod 1
 
GPU Node 2
   ↓
Inference Pod 2

This is one reason AI infrastructure autoscaling is more complicated than ordinary CPU workloads.


29. Node Selectors and Node Pools#

Suppose you have:

General Nodes
GPU Nodes

Your AI workload should not randomly land on a general node.

You can use scheduling constraints such as:

nodeSelector:
  workload: gpu

Conceptually:

Pod
 │
 └── nodeSelector: workload=gpu
                │
                ▼
           GPU Node Pool

We'll study scheduling deeply in Chapter 17.


30. Cluster Autoscaler Is Not HPA#

Let's make this extremely clear.

HPA asks:#

"How many application Pods do I need?"

Cluster Autoscaler asks:#

"How many worker nodes do I need to run those Pods?"

                    Application demand
                           │
                           ▼
                          HPA
                           │
                    Number of Pods
                           │
                           ▼
                      Scheduler
                           │
                 Enough node capacity?
                    │            │
                   YES           NO
                    │            │
                    ▼            ▼
                   Run      Cluster Autoscaler
                                  │
                                  ▼
                              More Nodes

31. Common Troubleshooting Scenario#

You run:

kubectl get pods

and see:

NAME                         STATUS
node-api-abc                 Running
node-api-def                 Running
node-api-ghi                 Pending
node-api-jkl                 Pending

Don't immediately assume application code is broken.

Run:

kubectl describe pod node-api-ghi

Look at:

Events

You might see:

Insufficient cpu

or:

Insufficient memory

Now you know:

Application may be fine
Scheduling capacity is the problem

32. Debugging Flow#

Use this mental checklist:

Pod Pending?
     │
     ▼
kubectl describe pod
     │
     ▼
Look at Events
     │
     ├── Insufficient CPU?
     │
     ├── Insufficient memory?
     │
     ├── Node selector?
     │
     ├── Taints/tolerations?
     │
     ├── Affinity?
     │
     └── PVC problem?

Not every Pending Pod is a Cluster Autoscaler problem.

That's very important.


33. What If the Problem Is a PVC?#

Suppose:

Pod Pending

and the reason is:

PVC not bound

Adding a node won't necessarily solve the problem.

Similarly:

nodeSelector mismatch

may require changing scheduling configuration rather than adding generic nodes.

Therefore:

Always inspect the Pod events before assuming the cluster needs more nodes.


34. Production Architecture#

A typical cloud application may look like:

                         INTERNET
                            │
                            ▼
                         Ingress
                            │
                            ▼
                         Service
                            │
              ┌─────────────┼─────────────┐
              ▼             ▼             ▼
            Pod           Pod           Pod
              └─────────────┬─────────────┘
                            │
                           HPA
                            │
                            ▼
                     Replica Count
                            │
                            ▼
                        Scheduler
                            │
                 insufficient capacity?
                            │
                            ▼
                  Cluster Autoscaler
                            │
                            ▼
                       Node Pool
                  ┌─────────┼─────────┐
                  ▼         ▼         ▼
                Node 1    Node 2    Node 3

This is the architecture you should remember.


35. Important Interview Questions#

Q1. What is Cluster Autoscaler?#

Cluster Autoscaler automatically adjusts the number of worker nodes when Pods cannot be scheduled because of insufficient capacity, and can remove underutilized nodes when workloads can be safely relocated.


Q2. HPA vs Cluster Autoscaler?#

HPA
→ Pods
 
Cluster Autoscaler
→ Nodes

Q3. When does Cluster Autoscaler usually scale up?#

When there are Pods that cannot currently be scheduled because the cluster lacks suitable capacity.


Q4. Does Cluster Autoscaler directly create Pods?#

No.

It adjusts node capacity.

The scheduler places Pods.


Q5. Does HPA create nodes?#

No.

HPA adjusts workload replicas.


Q6. What happens if max node count is reached?#

New Pods may remain:

Pending

if no existing node can accommodate them.


Q7. Why is kubectl describe pod important?#

Because the Events section often explains why a Pod cannot be scheduled.


Q8. What is a node pool?#

A logical group of similar worker nodes, often managed together and commonly used in cloud Kubernetes.


Q9. What is a PodDisruptionBudget?#

A mechanism that limits certain voluntary disruptions to help maintain application availability.


Q10. Does Cluster Autoscaler scale based simply on CPU percentage?#

No. A central signal is unschedulable Pods and whether changing node count would help scheduling. Node utilization and other constraints can also matter for scale-down decisions.


🧠 Chapter 16 Cheat Sheet#

HPA
 ↓
Scales Pods
 
Cluster Autoscaler
 ↓
Scales Nodes

Scale-up:

Traffic ↑
 ↓
HPA
 ↓
Pods ↑
 ↓
Pods Pending
 ↓
Cluster Autoscaler
 ↓
Nodes ↑
 ↓
Scheduler
 ↓
Pods Running

Scale-down:

Traffic ↓
 ↓
HPA
 ↓
Pods ↓
 ↓
Node capacity becomes unnecessary
 ↓
Cluster Autoscaler
 ↓
Nodes ↓

Important concepts:

Node
Node Pool
Pending Pod
Scheduling
Resource Requests
Cluster Autoscaler
PDB
Node Drain
Scale Up
Scale Down

🎯 Your Kubernetes Scaling Mental Model#

You should now be able to explain this entire chain in an interview:

"HPA increases the number of Pods when application demand causes configured metrics to exceed their targets. The scheduler attempts to place those Pods on available nodes. If Pods become unschedulable because the cluster lacks suitable capacity, Cluster Autoscaler can increase the node pool within its configured limits. Once capacity is available, the scheduler places the Pods. When demand falls, HPA can reduce replicas and Cluster Autoscaler can later remove nodes that are no longer needed, subject to scheduling and disruption constraints."

That's a strong production-level explanation.


Next → Chapter 17: Kubernetes Scheduling#

This is where we go deeper into how Kubernetes decides which node gets a Pod:

Pod
 │
 ▼
Scheduler
 │
 ├── CPU / Memory
 ├── Node Selector
 ├── Node Affinity
 ├── Taints
 ├── Tolerations
 ├── Pod Affinity
 ├── Pod Anti-Affinity
 └── Topology
        │
        ▼
     Best Node

This chapter is particularly important for production Kubernetes, multi-node clusters, GPU workloads, high availability, and interviews.

Finished this chapter?

Mark it as complete to track your mastery.

Previous ChapterChapter 15 — Horizontal Pod Autoscaler (HPA)Next ChapterChapter 17 — Kubernetes Scheduling
PrevNext