Autoscaling and Resource Management
Harry
· 11 Sep 2026
· 10 views
Requests and Limits
Every container should declare how much CPU and memory it needs (requests) and its hard ceiling (limits). The scheduler uses requests; limits protect neighbours:
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 500m
memory: 512MiHorizontal Pod Autoscaler (HPA)
The HPA changes the number of replicas based on observed CPU or custom metrics:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: web-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: web
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 60kubectl apply -f hpa.yaml
kubectl get hpaVertical and Cluster Autoscaling
- VPA - adjusts CPU/memory requests of pods based on usage.
- Cluster Autoscaler - adds/removes whole nodes as pods can't fit.
Key Points
- Always set requests and limits on every container.
- HPA scales pods; Cluster Autoscaler scales nodes.
- Test autoscaling with load before relying on it in production.