FullStack AI Hub
Studio
Cloud & Kubernetes · 02. Traffic & GitOps
9 min
6 steps
Intermediate

Cluster Autoscaling & GitOps Rollouts

Coordinate HPA/KEDA pod scaling with Karpenter node provisioning, and reconcile multi-cluster releases with GitOps.

Cloud & Kubernetes02. Traffic & GitOpsLesson 2 of 2
9 minIntermediate6 steps

Cluster Autoscaling & GitOps Rollouts

Coordinate HPA/KEDA pod scaling with Karpenter node provisioning, and reconcile multi-cluster releases with GitOps.

Queue Lag
18,400 msgs
Worker CPU
36%
HPA Replicas
2 (stuck)
Job Wait P95
4.5 min
Kubernetes Scheduler & HPA Lab7/7 Ready · 58% CPU
Wave 3/5
HPA Reconciliation Loop Scaling → 7 Replicas

desiredReplicas = ceil(4 × 110% / 70%) = 7. Any pod exceeding untainted node capacity stays Pending until Cluster Autoscaler adds nodes.

worker-az1
us-east-1a
4 pods
CPU8/8 cores (100%)
Memory12/16 GB (75%)
web-hpa-12c/3G
web-hpa-32c/3G
web-hpa-52c/3G
web-hpa-72c/3G
worker-az2
us-east-1b
3 pods
CPU6/8 cores (75%)
Memory9/16 GB (56%)
web-hpa-22c/3G
web-hpa-42c/3G
web-hpa-62c/3G
gpu-node-1
us-east-1c · Taint: gpu=true:NoSchedule
0 pods
CPU0/8 cores (0%)
Memory0/32 GB (0%)
Reserved for GPU tolerations
In This LessonStep 1 of 6
What You Will Master
  • ✓Scale pods on leading signals like queue depth and RPS (KEDA) rather than lagging CPU alone
  • ✓Eliminate Pending-pod stalls by pairing HPA with Karpenter just-in-time node provisioning
  • ✓Replace push-based CI cluster credentials with pull-based GitOps controllers (Argo CD)
  • ✓Automate canary promotion and rollback directly from Prometheus error-rate queries

Architectural Trade-Off Comparison Matrix

PatternBest ForKey Trade-Off
HPA (CPU / Memory)Predictable compute-bound APIs with gradual daily curvesLags sudden spikes and misses I/O-bound queue backlogs
KEDA Event ScalingQueue workers, LLM inference batches, and scale-to-zero jobsNeeds cooldown stabilization windows to prevent flapping
Karpenter ProvisionerLaunching right-sized spot/on-demand nodes in ~45 secSpot nodes need interruption draining handlers and fallbacks
Pull-Based GitOpsAuditable multi-cluster drift healing with zero prod creds in CISecrets must stay out of Git via ExternalSecrets

Step-by-Step Architectural Breakdown (6 Steps)

Full architectural walkthrough transcript and state transitions for Cluster Autoscaling & GitOps Rollouts.

STEP 01 · PROBLEMJump to step →

Why CPU-Only HPA Lags Behind Queue Spikes

A flash sale dumps 18,000 events into Kafka. Because workers are I/O-bound waiting on payment APIs, CPU sits at 36%—so a CPU-only HPA never scales while queue wait explodes.

watch:CPU is a lagging indicator for I/O-bound workers—scale on queue depth or concurrency instead.

CPU HPA LagQueue DepthI/O-Bound BottleneckLeading Metric
STEP 02 · SOLUTIONJump to step →

KEDA Event-Driven Pod Autoscaling

**KEDA** polls Kafka lag or Prometheus RPS every 15s and scales replicas from 0 to N, draining bursts rapidly while saving 65% off-peak.

good:Pair fast scale-up with a 5-minute scale-down stabilization window to prevent flapping.

KEDAScaledObjectStabilization WindowScale-to-Zero
STEP 03 · TECHNIQUEJump to step →

Two-Tier Scaling: HPA + Karpenter Nodes

When cluster VMs fill up, **Karpenter** watches Pending pods directly, launches right-sized On-Demand or Spot instances in ~45 sec, and consolidates idle nodes automatically.

idea:Keep 10% warm pause-pod headroom for latency-sensitive APIs while Karpenter provisions fresh VMs.

KarpenterBin-Packing ConsolidationSpot InterruptionHeadroom Buffer
STEP 04 · TECHNIQUEJump to step →

Pull-Based GitOps & Automated Canary Rollback

An in-cluster **GitOps Controller (Argo CD)** pulls signed manifests from Git and drives progressive canaries—auto-aborting if Prometheus 5xx exceeds 0.5%.

good:With GitOps, `git revert` rolls back production deterministically and manual drift heals automatically.

GitOps Pull ModelArgo RolloutsDrift Self-HealingSLO Metric Gate
STEP 05 · TRADE-OFFJump to step →

Autoscaling & GitOps Guardrails Trade-Off

Omit `spec.replicas` from Git manifests for autoscaled services so GitOps owns template/config while KEDA owns live scale—and always cap `maxReplicas` so bursts never crush downstream databases.

watch:Never let two controllers fight over the same `replicas` field.

Controller OwnershipMax Replicas CapDB Connection CeilingIgnoreDifferences
STEP 06 · RECAPJump to step →

Elastic Cloud Operations Recap

Elastic Kubernetes operations unite **KEDA** (event-driven pods), **Karpenter** (right-sized nodes), and **GitOps + SLO Rollouts** (auditable zero-drift shipping).

good:Bound autoscalers with `maxReplicas` and test failover under burst loads.

Elastic ScalingGitOpsProgressive DeliveryFinOps Consolidation

Related Production Deep-Dives & Simulators

Related Systems Course
Free · Verifiable Credential

FS-201Production LLM Engineer

Design an observable full-stack LLM product from capability validation through interfaces retrieval evaluation security and operations.

37 concepts~35h self-paced
Start Free Course
Weekly Engineering Dispatch

Get the weekly systems teardown

One technical note per week covering inference bottlenecks, retrieval harnesses, and commit-pinned teardowns.