Simple example to demonstrate cluster autoscaling behavior. Taken from: https://www.eksworkshop.com/.
- Use kubectl to deploy the
nginx_to_scale.yamlfile:kubectl apply -f examples/autoscaling/nginx_to_scale.yaml - Observe the running pods:
kubectl get pods
- your output should be similar to:
NAME READY STATUS RESTARTS AGE
nginx-to-scaleout-6fcd49fb84-7scd5 1/1 Running 0 5s
- Observe the cluster's current nodes:
kubectl get nodes. You should only see 2 nodes if the cluster has just been launched. - Scale the deployment:
kubectl scale --replicas=10 deployment/nginx-to-scaleout - Observe pods in pending state:
kubectl get pods - Eventually new nodes will be launched. You can observe the autoscaler logs with:
kubectl -n kube-system logs -f deployment/cluster-autoscaler - Once the new nodes are available, the pods in a pending state should now be running.
- To observe scaledown behavior, execute:
kubectl scale --replicas=1 deployment/nginx-to-scaleout
- the default behavior of the autoscaler is to watch nodes that could be removed for 10 minutes. once 10 minutes have passed, the nodes will be tainted and then removed.
kubectl delete -f nginx_to_scale.yaml