title | description |
---|---|
GCP Google Kubernetes Engine Cluster Autoscaling |
Implement GKE Cluster Autoscaler concept |
- Verify if GKE Cluster is created
- Verify if kubeconfig for kubectl is configured in your local terminal
# Configure kubeconfig for kubectl
gcloud container clusters get-credentials <CLUSTER-NAME> --region <REGION> --project <PROJECT>
# Replace Values CLUSTER-NAME, REGION, PROJECT
gcloud container clusters get-credentials standard-cluster-private-1 --region us-central1 --project kdaida123
# List Kubernetes Nodes
kubectl get nodes
- Test Cluster Autoscaler feature
- Go to Kubernetes Engine -> standard-cluster-private-1 -> NODES Tab -> default-pool -> Click on Edit
- Check Enable cluster autoscaler
- Size limits type
- Check Per zone limits
- Minimum number of nodes (per zone): 0
- Maximum number of nodes (per zone): 3
# List Pods
kubectl get pods
# Describe Pod (PENDING POD)
kubectl describe pod <PENDING-POD-NAME>
Observation:
1. Verify the pod events where we can find the autoscaling event triggered
# List Kubernetes Nodes
kubectl get nodes
Observation:
1. Nodes in NodePools will be increased from 3 to 4 (2 per zone max we configured)
# Scale-In the demo application to 1 pod
kubectl get pods
kubectl get nodes
kubectl scale --replicas=1 deploy myapp1-deployment
kubectl get pods
# List Kubernetes Nodes
kubectl get nodes
1. Nodes in NodePools will be decreased from 4 to 3 (Wait for 10 minutes for Nodes Scale-In)
# Delete Kubernetes Resources
kubectl delete -f kube-manifests