HPA (HorizontalPodAutoscaler)
What is HPA (HorizontalPodAutoscaler)?
HPA (HorizontalPodAutoscaler): Automatically scales the replica count of a workload up or down based on metrics like CPU utilisation or custom metrics. A HorizontalPodAutoscaler, or HPA, changes the number of pods in a Kubernetes Deployment based on load. When average CPU usage goes above a target, it adds pods; when load drops, it removes them again.
Frequently asked questions about HPA (HorizontalPodAutoscaler)
How is HPA (HorizontalPodAutoscaler) used in practice?
It keeps an application responsive during busy periods without paying for peak capacity all day. It can also scale on memory or custom metrics, such as requests per second or queue length.
What should you keep in mind with HPA (HorizontalPodAutoscaler)?
An HPA needs resource requests on the containers, because CPU usage is measured as a percentage of the request. Set sensible minimum and maximum replica counts, so a bug cannot scale you to a hundred pods. Remember that the database does not scale with it. More web pods mean more database connections, so check that your database can handle the maximum.
What does an example of HPA (HorizontalPodAutoscaler) look like?
apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: web spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: web minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: { type: Utilization, averageUtilization: 70 } At a glance
| Category | Kubernetes |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |