🎉 DevOps Interview Prep Bundle is live — 1000+ Q&A across 20 topicsGet it →
All Articles

What is Karpenter — Explained for Beginners

Karpenter is replacing Cluster Autoscaler in most EKS deployments. Here's what it actually does, how it's different from Cluster Autoscaler, and when to use it.

DevOpsBoysJun 3, 20264 min read
Share:Tweet

You've heard Karpenter mentioned as the "new way" to autoscale Kubernetes nodes. But what does it actually do, and why is it better than Cluster Autoscaler?


The Problem: Node Autoscaling

Your Kubernetes cluster has 5 nodes. A deployment scales up from 3 pods to 50 pods. The existing nodes are full. New pods are Pending.

Something needs to add more nodes. That "something" is the node autoscaler.


Cluster Autoscaler — The Old Way

Cluster Autoscaler watches for pending pods and scales up the node group (AWS Auto Scaling Group) when needed.

How it works:

  1. Pod goes Pending (not enough resources)
  2. Cluster Autoscaler notices
  3. CA checks which node group to scale up
  4. CA calls AWS API to increase ASG desired count
  5. New EC2 instance starts (~3-4 minutes)
  6. Instance joins cluster, kubelet runs
  7. Pod gets scheduled (~4-5 minutes total)

Limitations:

  • Tied to pre-configured node groups (you decide instance types upfront)
  • Can't mix instance types dynamically
  • Slow at recognizing over-provisioning
  • Configuration is complex for mixed workloads

Karpenter — The New Way

Karpenter watches for pending pods and launches the OPTIMAL EC2 instance directly — no node groups needed.

How it works:

  1. Pod goes Pending
  2. Karpenter sees the pod's requirements (CPU, memory, GPU, spot/on-demand)
  3. Karpenter calculates the optimal instance type for that exact workload
  4. Karpenter calls EC2 RunInstances API directly (faster than ASG)
  5. Instance joins cluster, pod gets scheduled (~2 minutes total)

The Key Difference: Direct Instance Provisioning

Cluster Autoscaler path:
Pod Pending → CA → ASG (pre-configured) → EC2 (pre-defined type)

Karpenter path:
Pod Pending → Karpenter → EC2 (optimal type, chosen at runtime)

Karpenter decides "this pod needs 4 vCPU and 16GB RAM — I'll launch a c5.xlarge OR m5.xlarge, whichever is cheapest right now."


NodePool and NodeClass: How Karpenter is Configured

yaml
# NodePool: constraints on what Karpenter can provision
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: default
spec:
  template:
    spec:
      requirements:
        # Allow these instance families
        - key: karpenter.k8s.aws/instance-family
          operator: In
          values: [c5, m5, r5, c5a, m5a]
          
        # Both spot and on-demand
        - key: karpenter.sh/capacity-type
          operator: In
          values: [spot, on-demand]
          
        # Only Linux
        - key: kubernetes.io/os
          operator: In
          values: [linux]
          
      nodeClassRef:
        apiVersion: karpenter.k8s.aws/v1
        kind: EC2NodeClass
        name: default
        
  # Cost optimization: consolidate nodes when possible
  disruption:
    consolidationPolicy: WhenUnderutilized
    consolidateAfter: 30s
    
  # Max cluster size
  limits:
    cpu: 1000
    memory: 1000Gi
---
# EC2NodeClass: AWS-specific config
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
  name: default
spec:
  amiSelectorTerms:
    - alias: al2023@latest    # Amazon Linux 2023
  subnetSelectorTerms:
    - tags:
        karpenter.sh/discovery: my-cluster
  securityGroupSelectorTerms:
    - tags:
        karpenter.sh/discovery: my-cluster
  role: KarpenterNodeRole

Spot Instance Optimization

Karpenter's biggest advantage: intelligent spot instance handling.

yaml
# Karpenter automatically:
# 1. Picks cheapest spot instance type that fits the pod
# 2. Watches for spot interruption notices
# 3. Cordons and drains the node before termination (2-minute warning)
# 4. Launches replacement immediately
 
# You just annotate your deployment:
spec:
  template:
    spec:
      nodeSelector:
        karpenter.sh/capacity-type: spot

No ASG configuration, no multiple node groups, no manual spot fleet management.


Consolidation: Scale Down Automatically

Karpenter doesn't just scale up — it consolidates underutilized nodes:

yaml
disruption:
  consolidationPolicy: WhenUnderutilized
  consolidateAfter: 30s  # Wait 30s after underutilization detected

If a node has pods that fit on existing nodes, Karpenter:

  1. Marks the node for consolidation
  2. Drains pods gracefully to other nodes
  3. Terminates the EC2 instance

This saves money automatically without cron jobs.


Install Karpenter on EKS

bash
# Prerequisites: EKS cluster, Helm
 
# Create IAM role for Karpenter
export CLUSTER_NAME=my-eks-cluster
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
export KARPENTER_NAMESPACE=kube-system
export KARPENTER_VERSION=1.0.0
 
# Install via Helm
helm registry logout public.ecr.aws
helm upgrade --install karpenter oci://public.ecr.aws/karpenter/karpenter \
  --version "${KARPENTER_VERSION}" \
  --namespace "${KARPENTER_NAMESPACE}" --create-namespace \
  --set "settings.clusterName=${CLUSTER_NAME}" \
  --set "settings.interruptionQueue=${CLUSTER_NAME}" \
  --set controller.resources.requests.cpu=1 \
  --set controller.resources.requests.memory=1Gi

Karpenter vs Cluster Autoscaler

FeatureKarpenterCluster Autoscaler
Provisioning speed~2 min~4-5 min
Instance flexibilityAny instance typePre-configured groups
Spot optimizationBuilt-inManual configuration
ConsolidationAutomaticBasic
Configuration complexityLowHigh (many node groups)
Cloud supportAWS, Azure (beta)All clouds

For new EKS deployments in 2026, Karpenter is the default choice. Cluster Autoscaler is still fine if you need multi-cloud support (Karpenter is primarily AWS-focused) or have existing node group configurations you don't want to change.

Learn Kubernetes autoscaling and cluster management with hands-on EKS labs at KodeKloud.

🔧

Today I Fixed

Short real fixes from production — posted daily

Browse fixes
Newsletter

Stay ahead of the curve

Get the latest DevOps, Kubernetes, AWS, and AI/ML guides delivered straight to your inbox. No spam — just practical engineering content.

Related Articles

Comments