Auto-Scaling in Kubernetes
Kubernetes supports three main types of scaling:
- Horizontal Pod Autoscaler (HPA): Scales pods based on CPU/memory.
- Vertical Pod Autoscaler (VPA): Adjusts resource requests/limits of pods.
- Cluster Autoscaler: Adds/removes nodes based on pod needs.
HPA Example:
kubectl autoscale deployment my-deployment \
--cpu-percent=50 \
--min=1 \
--max=10
Enable Cluster Autoscaler (EKS Example):
apiVersion: apps/v1
kind: Deployment
metadata:
name: cluster-autoscaler
spec:
template:
spec:
containers:
- image: k8s.gcr.io/autoscaling/cluster-autoscaler:v1.20.0
name: cluster-autoscaler
command:
- ./cluster-autoscaler
- --cloud-provider=aws
- --nodes=1:10:node-group-name