Scenario
An e-commerce platform runs Kubernetes on AWS EKS with Cluster Autoscaler (CA) and Horizontal Pod Autoscaler (HPA). They experience unexpected cost spikes and performance degradation: high latency during peak hours, and node utilization below 30% during off-peak.
Symptoms
- Monthly cloud bill increases by >25%
- Node CPU average utilization below 20% during off-peak
- HPA triggers frequently but new Pods are slow to serve requests
- Cluster Autoscaler logs show "scale-up blocked" errors
Diagnosis
- Check HPA configuration:
kubectl get hpa -n <namespace>to review target metrics. Verify resource requests and limits are set correctly. - Analyze CA logs:
kubectl logs -n kube-system deployment/cluster-autoscalerto find reasons for scaling failures (e.g., node group max limits, AWS resource quotas). - Inspect node utilization:
kubectl top nodesandkubectl describe nodesfor resource allocation and idle capacity. - Use AWS Cost Explorer with tag filters to identify wasted spend on idle nodes.
Commands
# Check HPA status
kubectl get hpa --all-namespaces
# View Cluster Autoscaler logs
export CA_POD=$(kubectl get pods -n kube-system -l app.kubernetes.io/name=aws-cluster-autoscaler -o jsonpath='{.items[0].metadata.name}')
kubectl logs -n kube-system $CA_POD --tail=50
# Adjust node group min/max (via AWS CLI)
aws autoscaling update-auto-scaling-group --auto-scaling-group-name <ASG_NAME> --min-size 2 --max-size 10
# Set pod resource requests & limits (example deployment)
kubectl set resources deployment <app> -n <ns> --requests=cpu=500m,memory=512Mi --limits=cpu=1,memory=1Gi
Risk Controls
- Before changing node group sizes, create a PodDisruptionBudget for critical services:
kubectl create pdb <name> --selector=app=<app> --min-available=2 - Configure CA scale-down thresholds (e.g., utilization <50% for 10 minutes) via CA startup arguments: add
--scale-down-utilization-threshold=0.5 --scale-down-delay-after-add=10m - Use node affinity and anti-affinity to prevent disruptive workloads from consuming burst capacity
Rollback
- Restore original node group sizes:
aws autoscaling update-auto-scaling-group --auto-scaling-group-name <ASG_NAME> --min-size <original> --max-size <original> - Rollback HPA resource changes:
kubectl rollout undo deployment/<deployment-name> -n <namespace> - Revert CA parameters by editing the deployment:
kubectl edit deployment cluster-autoscaler -n kube-systemand restore previous arguments
Verification
- Monitor cost trends: Use AWS Cost Explorer or Kubecost to observe daily cost changes over the next week.
- Validate scaling response: Run a load test (e.g., with k6) to stress the system and confirm HPA and CA scale without delays.
- Check node utilization:
kubectl top nodesandkubectl describe nodesto ensure off-peak utilization rises above 40%.
When to Submit an OpsGlobal Ticket
- Scaling delays persist even after adjustments (no new nodes within 5 minutes)
- CA logs show "Failed to find node group" or AWS API throttling errors
- Need assistance configuring custom metrics HPA (e.g., based on queue length)
- Frequent Spot instance interruptions affecting workload stability
Use cases
Useful for teams handling Cloud Migration issues and needing a clear troubleshooting and delivery workflow.
Problem background
A practical guide to diagnosing and optimizing Kubernetes Cluster Autoscaler and HPA for cost efficiency, with step-by-step commands, risk controls, and verification methods. Based on a real-world e-commerce scenario on AWS EKS.
Troubleshooting steps
Confirm impact and recent changes, collect logs, configuration and metrics, then apply fixes from low to high risk.
Command examples
Replace sample resource names with real values and store passwords, tokens and keys in environment variables.
Risks
Before production changes, confirm backups, access boundaries, change windows and rollback paths.
Rollback plan
Keep original configuration and release versions; roll back config, images or database changes if metrics degrade.
Deliverables
Root-cause notes, key commands, remediation steps, verification results and follow-up recommendations.
Need help with a similar technical issue?
If your servers, Kubernetes, Docker, CI/CD, databases or monitoring systems have similar issues, submit logs and config files for remote diagnosis.