Kubectl Scale and Autoscale

Handle traffic spikes with manual scaling and HPA.

  • kubectl scale
  • hpa
  • autoscale
  • metrics-server
  • replicas

Kubectl Scale and Autoscale

Handle traffic spikes with manual scaling and HPA.

Commands

CommandWhat it does
kubectl scale deploy/api --replicas=5Manual replica count
kubectl autoscale deploy/api --min=2 --max=10 --cpu-percent=60CPU-based HPA
kubectl get hpaHPA status and current load
kubectl top podsLive usage to validate thresholds
kubectl describe hpa apiWhy it scaled (events)

Example

kubectl scale deploy/api --replicas=5
kubectl autoscale deploy/api --min=2 --max=10 --cpu-percent=60
kubectl get hpa -w

FAQ

HPA needs what to work?

metrics-server (or custom metrics) plus resource requests on pods — without requests, CPU % is meaningless.

HPA vs VPA?

HPA changes replica count; VPA changes per-pod requests. Rarely combine both on CPU/memory.

SSS

HPA needs what to work?
metrics-server (or custom metrics) plus resource requests on pods — without requests, CPU % is meaningless.
HPA vs VPA?
HPA changes replica count; VPA changes per-pod requests. Rarely combine both on CPU/memory.

Kubernetes