1. Answers
  2. Deploy The Cluster-autoscaler Helm Chart On AWS EKS

Deploy the Cluster-Autoscaler Helm Chart on AWS EKS

Introduction

In this guide, we will deploy the cluster-autoscaler Helm chart on an AWS EKS cluster using Pulumi. The cluster-autoscaler is a tool that automatically adjusts the size of the Kubernetes cluster when there are pending pods that cannot be scheduled due to insufficient resources or when there are underutilized nodes.

Step-by-Step Explanation

Step 1: Set up Pulumi and AWS

  1. Ensure you have Pulumi installed. If not, follow the installation guide.
  2. Configure Pulumi to use AWS as the cloud provider. You can do this by setting up your AWS credentials. Refer to the AWS setup guide.
  3. Create a new Pulumi project using TypeScript:
    pulumi new aws-typescript
    

Step 2: Create an EKS Cluster

  1. Define the EKS cluster configuration in your index.ts file:
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    import * as eks from "@pulumi/eks";
    
    const vpc = new aws.ec2.Vpc("vpc", {
        cidrBlock: "10.0.0.0/16",
    });
    
    const subnet = new aws.ec2.Subnet("subnet", {
        vpcId: vpc.id,
        cidrBlock: "10.0.1.0/24",
    });
    
    const cluster = new eks.Cluster("eksCluster", {
        vpcId: vpc.id,
        subnetIds: [subnet.id],
    });
    
    export const kubeconfig = cluster.kubeconfig;
    

Step 3: Deploy the Cluster Autoscaler Helm Chart

  1. Install the @pulumi/kubernetes package:
    npm install @pulumi/kubernetes
    
  2. Add the Helm chart deployment to your index.ts file:
    import * as k8s from "@pulumi/kubernetes";
    
    const clusterAutoscaler = new k8s.helm.v3.Chart("cluster-autoscaler", {
        chart: "cluster-autoscaler",
        version: "9.10.7",
        fetchOpts: {
            repo: "https://kubernetes.github.io/autoscaler",
        },
        values: {
            autoDiscovery: {
                clusterName: cluster.eksCluster.name,
            },
            awsRegion: aws.config.region,
            rbac: {
                create: true,
            },
        },
    }, { provider: cluster.provider });
    

Step 4: Deploy the Stack

  1. Run pulumi up to create the resources.
  2. Verify the deployment by checking the status of the Helm release and the EKS cluster.

Summary

In this guide, we successfully deployed the cluster-autoscaler Helm chart on an AWS EKS cluster using Pulumi. We covered the steps to set up Pulumi with AWS, create an EKS cluster, deploy the Helm chart, and verify the deployment. The cluster-autoscaler helps in managing the cluster size dynamically based on the resource requirements, ensuring efficient utilization of resources.

Full Code Example

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as eks from "@pulumi/eks";
import * as k8s from "@pulumi/kubernetes";

// Create a VPC
const vpc = new aws.ec2.Vpc("vpc", {
    cidrBlock: "10.0.0.0/16",
});

// Create a Subnet
const subnet = new aws.ec2.Subnet("subnet", {
    vpcId: vpc.id,
    cidrBlock: "10.0.1.0/24",
});

// Create an EKS Cluster
const cluster = new eks.Cluster("eksCluster", {
    vpcId: vpc.id,
    subnetIds: [subnet.id],
});

// Export the kubeconfig
export const kubeconfig = cluster.kubeconfig;

// Deploy the Cluster Autoscaler Helm Chart
const clusterAutoscaler = new k8s.helm.v3.Chart("cluster-autoscaler", {
    chart: "cluster-autoscaler",
    version: "9.10.7",
    fetchOpts: {
        repo: "https://kubernetes.github.io/autoscaler",
    },
    values: {
        autoDiscovery: {
            clusterName: cluster.eksCluster.name,
        },
        awsRegion: aws.config.region,
        rbac: {
            create: true,
        },
    },
}, { provider: cluster.provider });

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up