k8wiz
Playground

Autoscale a Deployment with an HPA

Intermediate · Kubernetes · about 12 min

This follows the HPA walkthrough from the Kubernetes docs, with one twist: the Deployment was written without CPU requests.

Loading the playground...

About this scenario

This follows the HPA walkthrough from the Kubernetes docs, with one twist: the Deployment was written without CPU requests.

An HPA works in percent of the requested CPU, so without requests it has nothing to divide by.

Objectives

  1. Create an HPA targeting 50% CPU, 1 to 10 replicas
  2. Give the container a CPU request so the HPA can compute utilization
  3. Send load and get to at least 3 replicas

What you'll practice

  • The HPA divides measured CPU by requested CPU. No requests, no utilization, no scaling.
  • desiredReplicas = ceil(currentReplicas × current / target). It acts every 15 seconds.
  • Scale-down waits for a 5-minute stabilization window, so delete the load generator and use sim ff 300 to see it.

How the playground works

The cluster runs entirely in your browser: a simulated API server, scheduler, kubelets and controllers, with virtual nodes in three zones. kubectl output follows the real formats, errors use the real messages, and the add-ons (CSI storage, Traefik, Envoy Gateway, cert-manager, Flux, Argo CD) behave like their real counterparts for the common paths. It's a simulation, so some behavior is simplified. Your progress is saved in this browser.