Kubernetes:HorizontalPodAutoscaler
lastmod 2024-06-11created 2024-06-112 edits
Kubernetes also has a built-in basic autoscaling feature called HPA (Horizontal Pod Autoscaler). HPA increases or decreases the number of pods run by a Deployment based on CPU utilization.
Example
yaml file:
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: kubernetes-simple-app-hpa
namespace: default
spec:
maxReplicas: 10
minReplicas: 1
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: kubernetes-simple-app
targetCPUUtilizationPercentage: 30
A rough calculation of how autoscaling is performed is as follows.