Interview Prep/Kubernetes/Resources, autoscaling and scheduling

How do you configure an HPA on CPU?

BeginnerScenarioResources, autoscaling and scheduling
Answer

Situation read → Traffic varies during the day and you want automatic scaling.

What I'd do →

  1. Ensure metrics-server runs: kubectl top pods
  2. Set CPU requests on the Deployment, since utilisation is relative to requests
  3. kubectl autoscale deploy web --cpu-percent=70 --min=3 --max=20
  4. Check with kubectl get hpa and kubectl describe hpa web
  5. Load test and watch scaling events

Why → HPA computes desired replicas from current metric divided by target.

Interview tip → Remember: no requests means HPA shows <unknown>.

All Kubernetes questions Roadmap: Kubernetes core

More on Resources, autoscaling and scheduling