IntermediateLesson 18 of 35
Horizontal Pod Autoscaler
Scale replica counts with load.
bash
kubectl autoscale deployment web --cpu-percent=70 --min=2 --max=10yaml
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 }Needs metrics-server and CPU requests on the pods (utilisation is relative to the request). Custom metrics (queue length, requests per second) need an adapter such as KEDA.