How-To: AWS EKS auto-scaling instructions

So, unlike GCP, AWS EKS doesn't enable autoscaling by default. You need to install autoscaler specific to AWS EKS cluster. Thanks to helm, we can install cluster-autoscaler chart. This doc outlines steps as suggested in the Readme of helm chart.

You can follow this with three simple steps. Let's get right into it!

1. Update IAM role

I assume you've already setup Dockup Agent. If not you can head over to Set-up Dockup Agent on AWS to do so.

Once worker nodes are created using cloud formation, go to "Resources" tab and search for IAM::Role. You should see something like this:

Updating IAM Role

Visit the instance role, and add an inline policy in JSON format.

Updating policies
Policy Rules

Here is the JSON Snippet that you can directly paste, review it and apply the policy.

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeTags",
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup"
],
"Resource": "*"
}
]
}

2. Add tags to node group for auto discovery

Again go to "Resources" tab of worker nodes cloud formation stack and search for "NodeGroup". You should see something like this:

Apply the following tags

k8s.io/cluster-autoscaler/enabled = true
kubernetes.io/cluster/<ClusterName> = owned

3. Install auto-scaler helm chart

Run cluster autoscaler helm chart and you should have auto-scaling in place.

$ helm repo add dockup https://helm-charts.getdockup.com
$ helm install \
--set autoDiscovery.clusterName="<cluser-name-that-you-have-created>" \
--set awsRegion="<region-where-cluster-exists>" \
--set sslCertPath=/etc/kubernetes/pki/ca.crt \
--set rbac.create=true \
--name=dockup-autoscaler \
stable/cluster-autoscaler

As you deploy, you can see nodes coming up and going down using watch command kubectl get nodes --watch