Kubectl Scale and Autoscale
Handle traffic spikes with manual scaling and HPA.
- kubectl scale
- hpa
- autoscale
- metrics-server
- replicas
Kubectl Scale and Autoscale
Handle traffic spikes with manual scaling and HPA.
Commands
| Command | What it does |
|---|---|
kubectl scale deploy/api --replicas=5 | Manual replica count |
kubectl autoscale deploy/api --min=2 --max=10 --cpu-percent=60 | CPU-based HPA |
kubectl get hpa | HPA status and current load |
kubectl top pods | Live usage to validate thresholds |
kubectl describe hpa api | Why it scaled (events) |
Example
kubectl scale deploy/api --replicas=5
kubectl autoscale deploy/api --min=2 --max=10 --cpu-percent=60
kubectl get hpa -w
FAQ
HPA needs what to work?
metrics-server (or custom metrics) plus resource requests on pods — without requests, CPU % is meaningless.
HPA vs VPA?
HPA changes replica count; VPA changes per-pod requests. Rarely combine both on CPU/memory.
Câu hỏi thường gặp
HPA needs what to work?
metrics-server (or custom metrics) plus resource requests on pods — without requests, CPU % is meaningless.
HPA vs VPA?
HPA changes replica count; VPA changes per-pod requests. Rarely combine both on CPU/memory.
Kubernetes
Kubectl Config and Context
Point kubectl at the right cluster and switch contexts safely.
Kubectl Pods
Inspect pods, describe failures, and get a shell inside.
Kubectl Deployments
Create, update, and inspect Deployments that own your pods.
Kubectl Services
Expose pods stably with ClusterIP, NodePort, and LoadBalancer.