This part of the repository complements the AWS EKS Cluster creation by implementing the Kubernetes Cluster Autoscaler. The Autoscaler scales the nodes of a cluster according to the workloads, i.e. pods that are to be scheduled. It ensures that no empty nodes are running as well as that new nodes are scheduled if pods are pending to be deployed. Thus, it complements the EC2 Autoscaling groups (by adhering to the node limits set), which implements scaling based on utilization but neglects the pods to be scheduled.
NOTE
The Cluster Autoscaler will be deployed as a Kubernetes Deployment within the actual EKS cluster. Currently, no adequate and official Terraform module has been found for this purpose. Therefore, the implementation relies on the official commands from the Kubernetes Cluster Autoscaler Github Repo.
- Provisioned EKS Cluster: Baseline Architecture.
- Connection to the cluster (via
aws eks --region us-east-2 update-kubeconfig --name eks-cluster
). - AWS CLI - A command line tool for interacting with AWS services.
- kubectl - A command line tool for working with Kubernetes clusters.
- Execute
bash cluster-autoscaler.sh
. - Deploy the application, for example: ALB.
To easily test the Cluster Autoscaler, we increase the replicas of some services of the application by executing:
kubectl -n teastore-namespace --replicas=2 deployment/teastore-webui
. Increase replicas depending on the free cluster capacity.kubectl -n teastore-namespace --replicas=2 deployment/teastore-recommender
.- Monitor the status of the pods by executing:
kubectl -n teastore-namespace get pods
. - Monitor the amount of nodes by executing:
kubectl get nodes
.
After some minutes new nodes should be in state ready and all pods are running.
- Delete application via
kubectl delete -f TeaStore\teastore-alb.yaml
from within the baseline architecture directoy. - Run
bash shutdown-autoscaler.sh
and enter the name of the cluster (eks-cluster). - Delete Cluster:
Terraform destroy
confirm withyes
. This may take up to 20 min.