HorizontalPodAutoscaler (HPA) automatically adjusts a Kubernetes workload’s pod count as demand changes. It scales up when average CPU usage exceeds a target and scales down while preserving configured minimum capacity. section 6.3
A practical HPA setup includes:
- Define CPU and memory resource requests and limits on the Deployment so Kubernetes can measure pod usage. section 6.3
- Set minimum and maximum replicas, such as 3 and 20, to constrain elasticity and preserve baseline availability. section 6.3
- Use resource metrics or expose custom metrics such as requests per second through the Metrics Server and Prometheus Adapter. section 6.3
- Pair workload scaling with Cluster Autoscaler when existing nodes cannot accommodate newly created pods. section 6.3
Scaling a high-traffic API
Run kubectl autoscale deployment api-deployment --cpu-percent=70 --min=3 --max=20 to scale an API between three and twenty pods around 70% average CPU utilization. For multi-metric policies, use an autoscaling/v2 manifest targeting a Deployment and combining CPU utilization with average HTTP requests per second. section 6.3



