Infra & Cloud yaml Intermediate

Kubernetes HorizontalPodAutoscaler

Auto-scale a deployment between 2 and 10 pods based on CPU and memory utilisation.

yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: myapp-hpa
spec:
  scaleTargetRef: { apiVersion: apps/v1, kind: Deployment, name: myapp }
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource: { name: cpu, target: { type: Utilization, averageUtilization: 70 } }

Prerequisites

  • Kubernetes >= 1.26
  • metrics-server

Pro Tips

  • → Install metrics-server before applying HPA.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
yaml
Level
Intermediate
Read time
3 min
Published
Dec 2024
License
Commercial License

Newsletter

New modules every week, directly to your inbox.