🎉 DevOps Interview Prep Bundle is live — 1000+ Q&A across 20 topicsGet it →
All Articles

Kubernetes HPA Not Scaling: 6 Causes and Exact Fixes

HorizontalPodAutoscaler not scaling up or stuck at min replicas? These 6 fixes cover missing Metrics Server, wrong metric name, resource requests not set, and cooldown periods — with exact kubectl commands.

Shubham2 min read
Share:Tweet

HPA (HorizontalPodAutoscaler) not scaling is one of those issues where nothing looks wrong but replicas stay at minimum. Here are the six most common causes, from most to least common.

Quick Diagnosis

bash
# Check HPA status
kubectl describe hpa <hpa-name> -n <namespace>

Cause 1: Metrics Server Not Installed

HPA for CPU/memory requires Metrics Server.

Fix:

bash
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
kubectl top pods

Cause 2: Resource Requests Not Set

HPA calculates CPU utilization as actual_usage / requested. No request = formula breaks.

Fix:

yaml
resources:
  requests:
    cpu: "200m"
    memory: "256Mi"
  limits:
    cpu: "1000m"
    memory: "512Mi"

Cause 3: HPA Cooldown Period

Default scale-down cooldown is 5 minutes.

yaml
behavior:
  scaleDown:
    stabilizationWindowSeconds: 60
  scaleUp:
    stabilizationWindowSeconds: 0

Cause 4: Metric Below Target

bash
kubectl get hpa -n production
# 40%/70% → no scale needed, HPA is working correctly

Cause 5: Wrong Custom Metric Name

bash
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/" | jq '.resources[].name'

Cause 6: MaxReplicas Reached

bash
kubectl patch hpa myapp-hpa -n production --type='json' \
  -p='[{"op": "replace", "path": "/spec/maxReplicas", "value": 50}]'

Correct HPA (autoscaling/v2)

yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: myapp-hpa
  namespace: production
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: myapp
  minReplicas: 2
  maxReplicas: 30
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 80

More Kubernetes autoscaling? Read our KEDA event-driven autoscaling guide and Kubernetes VPA vs HPA vs KEDA comparison.

🔧

Today I Fixed

Short real fixes from production — posted daily

Browse fixes
Newsletter

Stay ahead of the curve

Get the latest DevOps, Kubernetes, AWS, and AI/ML guides delivered straight to your inbox. No spam — just practical engineering content.

Related Articles

Comments