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 →
- Ensure metrics-server runs:
kubectl top pods - Set CPU requests on the Deployment, since utilisation is relative to requests
kubectl autoscale deploy web --cpu-percent=70 --min=3 --max=20- Check with
kubectl get hpaandkubectl describe hpa web - 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>.
More on Resources, autoscaling and scheduling
How do you choose requests and limits for a new service?BeginnerPods are Pending with `0/6 nodes are available: 6 Insufficient cpu`. What do you do?IntermediateExplain QoS classes and which pods get evicted first.IntermediateCPU limits cause latency spikes though average usage is low. Why and what is the fix?IntermediateHPA shows `<unknown>/70%` for CPU. What do you do?IntermediateYou need to scale on queue length or requests per second, not CPU. How?Intermediate