Kubernetes auto-scaling comes in three layers: Horizontal Pod Autoscaler (HPA) for replica count, Vertical Pod Autoscaler (VPA) for pod resource requests, and Cluster Autoscaler for node count. You’ll typically use HPA first, add Cluster Autoscaler when nodes run out of capacity, and use VPA carefully — it restarts pods and can fight with HPA if both target the same workload.
1. Horizontal Pod Autoscaler (HPA)
The Horizontal Pod Autoscaler adjusts replica count for a Deployment, StatefulSet, or ReplicationController based on CPU, memory, or custom metrics.
Prerequisites
Install the Metrics Server so HPA can read resource utilization:
bash
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Your workload must have resource requests set. Example Deployment:
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app-container
image: nginx
resources:
requests:
cpu: "250m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "256Mi"
Create the HPA
Scale on CPU utilization (70% average across pods):
yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-app-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
Apply and verify:
bash
kubectl apply -f my-app-hpa.yaml
kubectl get hpa
2. Vertical Pod Autoscaler (VPA)
VPA watches actual usage and updates the pod’s resource requests. In “Auto” mode it evicts pods so they restart with new requests — this can cause downtime. Do not run VPA and HPA on the same workload unless VPA is in “Off” or “Initial” mode, or you’ve configured HPA to use custom metrics only.
Install VPA
Apply the official components (includes admission controller, recommender, updater):
bash
kubectl apply -f https://github.com/kubernetes/autoscaler/releases/download/vertical-pod-autoscaler-1.2.0/vpa-release-1.2.0.yaml
Create a VPA object
yaml
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: my-app-vpa
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app
updatePolicy:
updateMode: "Auto" # Options: "Off", "Initial", "Auto"
Apply and check recommendations:
bash
kubectl apply -f my-app-vpa.yaml
kubectl get vpa my-app-vpa -o yaml
3. Cluster Autoscaler
Cluster Autoscaler adds or removes nodes when pods are pending due to insufficient resources or when nodes are underutilized. There is no single generic manifest — you must deploy the version built for your cloud provider (AWS, GCP, Azure, etc.) and configure cloud-provider flags, IAM roles, and node group labels.
Typical setup
- Enable node pool auto-scaling in your managed Kubernetes service (EKS, GKE, AKS).
- Deploy the Cluster Autoscaler image matching your Kubernetes minor version.
- Set
--cloud-providerand any provider-specific flags (e.g.,--nodes=2:10:my-node-groupfor AWS). - Run it in the
kube-systemnamespace with appropriate RBAC.
Check logs to verify scaling decisions:
bash
kubectl logs -f deployment/cluster-autoscaler -n kube-system
Operational notes
- Monitoring: Wire up Prometheus/Grafana or the Kubernetes Dashboard to watch HPA/VPA/CA metrics and scaling events.
- Testing: Generate load (e.g.,
heyorwrk) and confirm each autoscaler reacts as expected. - Resource requests: HPA and VPA both depend on accurate
requestsin pod specs. Missing or wildly wrong requests break scaling logic. - Custom metrics: For HPA scaling on non-resource metrics (queue depth, latency), deploy the Prometheus Adapter and define
ExternalorPodsmetric types.

Ali YAZICI is a Senior IT Infrastructure Manager with 15+ years of enterprise experience. While a recognized expert in datacenter architecture, multi-cloud environments, storage, and advanced data protection and Commvault automation , his current focus is on next-generation datacenter technologies, including NVIDIA GPU architecture, high-performance server virtualization, and implementing AI-driven tools. He shares his practical, hands-on experience and combination of his personal field notes and “Expert-Driven AI.” he use AI tools as an assistant to structure drafts, which he then heavily edit, fact-check, and infuse with my own practical experience, original screenshots , and “in-the-trenches” insights that only a human expert can provide.
If you found this content valuable, [support this ad-free work with a coffee]. Connect with him on [LinkedIn].





