Table of contents
No headings in the article.
This blog is Part 7 of the blog series it is recommended that you read the previous blogs before this one. Hereis the Part 1 of the series.
Clone the project repository-
Cluster autoscaler scales the nodes in the cluster horizontally. We need to use the cluster autoscaler so that under heavy traffic, nodes get scaled. We need cluster autoscaler for one more reason.
We have the pod's resource requirement such that (more than 50% of CPU and Memory of Node) the node can only run a single pod. If we update the application and the CI/CD pipeline gets activated, when the new application is deployed in the cluster it will fail to deploy successfully without cluster autoscaler. The reason for this will be the existing node doesn't have enough resources to provide to the new application's pod and there is no new node available so in this case the autoscaler will act and provision a new node for the new application pod.
On AWS, Cluster Autoscaler utilizes Amazon EC2 Auto Scaling Groups to manage node groups. Cluster Autoscaler typically runs as a Deployment
in your cluster.
In this blog, I will give a brief tutorial to give permissions for autoscaler. This manifest resides in the /Manifests/cluster-autoscaler.yaml
project location. The manifest is very big and I have made it from the aws documentation and mostly manifest is copied from there. You do not need to understand the full manifest, hence I am not showing the manifest in the blog but you can see this in the project directory.
The documentation of the cluster autoscaler on AWS is below
You need to go to your AWS IAM node role and create an inline policy there. Paste the inline policy below in the JSON mode
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeScalingActivities",
"autoscaling:DescribeTags",
"ec2:DescribeInstanceTypes",
"ec2:DescribeLaunchTemplateVersions"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"ec2:DescribeImages",
"ec2:GetInstanceTypesFromInstanceRequirements",
"eks:DescribeNodegroup"
],
"Resource": [
"*"
]
}
]
}
Attach this inline policy in the node role.
This is all you have to do to make your autoscaler work.
This is it for this blog, In the next blog we will finally deploy the microservices application on AWS.
Share the blog on socials and tag me onXandLinkedInfor the #buildinpublic initiative.
******Thank you for reading๐๐******