The One Trick for Deploying Cluster Autoscaler on Amazon EKS Cluster Using Helm That Nobody Talks About

The One Trick for Deploying Cluster Autoscaler on Amazon EKS Cluster Using Helm That Nobody Talks About

Overview :-

Deploying the Cluster Autoscaler on Amazon EKS can be a challenging task, especially when using Helm. While many resources cover the basic steps, there’s one crucial trick that often goes unmentioned. This blog post will reveal this lesser-known technique and guide you through the entire process.

Prerequisites :-

Before we dive into the deployment process, ensure you have the following:

An active Amazon EKS cluster Helm installed on your local machine
* AWS CLI configured with appropriate permissions
* kubectl installed and configured to interact with your EKS cluster

\> Tip: Double-check your AWS IAM permissions to ensure smooth deployment.

Procedure :-

1. Add the Cluster Autoscaler Helm repository

First, add the official Cluster Autoscaler Helm repository:

helm repo add autoscaler https://kubernetes.github.io/autoscaler
helm repo update

2. Create IAM policy for Cluster Autoscaler

The Cluster Autoscaler needs specific permissions to interact with AWS services. Create an IAM policy with the required permissions:

aws iam create-policy - policy-name AmazonEKSClusterAutoscalerPolicy - policy-document file://cluster-autoscaler-policy.json

3. Create IAM role for Cluster Autoscaler

Next, create an IAM role and attach the policy:

eksctl create iamserviceaccount \
 - cluster=<your-cluster-name> \
 - namespace=kube-system \
 - name=cluster-autoscaler \
 - attach-policy-arn=arn:aws:iam::<your-account-id>:policy/AmazonEKSClusterAutoscalerPolicy \
 - override-existing-serviceaccounts \
 - approve

4. Deploy Cluster Autoscaler using Helm

Now, here’s the trick that often goes unmentioned: When deploying the Cluster Autoscaler using Helm, you need to set the awsRegion value explicitly. This ensures that the autoscaler works correctly with your specific AWS region:

helm install cluster-autoscaler autoscaler/cluster-autoscaler \
 - namespace kube-system \
 - set autoDiscovery.clusterName=<your-cluster-name> \
 - set awsRegion=<your-aws-region> \
 - set rbac.serviceAccount.create=false \
 - set rbac.serviceAccount.name=cluster-autoscaler

5. Verify the deployment

Check if the Cluster Autoscaler pod is running:

kubectl get pods -n kube-system | grep cluster-autoscaler

You should see the pod in a ‘Running’ state.

Conclusion :-

By explicitly setting the awsRegion value when deploying the Cluster Autoscaler with Helm, you ensure that it works correctly with your specific AWS region. This small but crucial step can save you hours of troubleshooting and ensure your EKS cluster scales efficiently.

Remember to monitor your cluster’s performance and adjust the autoscaler settings as needed. Happy scaling!