Horizontal Pod Autoscaling (HPA)
Install Metrics Server
Metrics Server collects resource metrics from Kubelets and exposes them in Kubernetes apiserver through Metrics API for use by Horizontal Pod Autoscaler and Vertical Pod Autoscaler. Metrics API can also be accessed by kubectl top
, making it easier to debug autoscaling pipelines.
helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
helm upgrade --install metrics-server metrics-server/metrics-server -n kube-system
HPA Resource
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: skills
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: skills
minReplicas: 2
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
behavior:
scaleDown:
stabilizationWindowSeconds: 60