Installing and Configuring Karpenter on Fargate for Autoscaling in Amazon EKS
Doing less to improve the efficiency and cost of running workloads.
karpenter
namespace. Doing so will cause all pods deployed into this namespace to run on EKS Fargate.
About | |
---|---|
✅ AWS experience | 200 - Intermediate |
⏱ Time to complete | 30 minutes |
🧩 Prerequisites | - AWS Account |
📢 Feedback | Any feedback, issues, or just a 👍 / 👎 ? |
⏰ Last Updated | 2024-01-19 |
- Install the latest version of kubectl. To check your version, run:
kubectl version
. - Install the latest version of eksctl. To check your version, run:
eksctl info
. - Install the latest version of Helm CLI
eksctl
cluster template that follows, you'll build an Amazon EKS cluster with Fargate profile to provide the compute capacity we need to run the core clusters components in the karpenter and kube-system namespaces. It configures the following components:- Fargate Profile: AWS Fargate is a compute engine for EKS that removes the need to configure, manage, and scale EC2 instances. Fargate ensures Availability Zone spread while removing the complexity of managing EC2 infrastructure and works to ensure that pods in a Replica Service are balanced across Availability Zones.
- Authentication: Necessary IAM Roles for Service Accounts (IRSAs) mappings to enable communication between Kubernetes pods and AWS services. This includes the Karpenter Controller responsible for provisioning EC2 compute capacity needed in the cluster. Additionally, an OpenID Connect (OIDC) endpoint enables seamless and secure communication.
- Identity Mappings: Necessary mapping for the Karpenter IAM principal and the required cluster's role-based access control (RBAC) configuration in the Amazon EKS control plane.
- Sample Application Deployment: Create a sample deployment to validate that Karpenter autoscales compute capacity needed as pod counts increase.
cluster config
, you'll define the settings for Fargate profile to provide the compute capacity needed by Karpenter and also core cluster such as CoreDNS.- Copy and paste the content below in your terminal to define your environment variable parameters
- Verify the environment variables with the command below:
- Copy and paste the content below in your terminal to use CloudFormation to set up the infrastructure needed by the EKS cluster.

Now, we're ready to create our Amazon EKS cluster. This process takes several minutes to complete. If you'd like to monitor the status, see the AWS CloudFormation console and change the region if you are creating the cluster in a different AWS region.
- Copy and paste the content below in your terminal to create the Amazon EKS cluster.
- Verify the cluster creation by executing the commands below in your terminal:
- Logout of helm registry to perform an unauthenticated pull against the public ECR just in case you were logged in.
- Proceed to install Karpenter with the command below:
Running
state with the following command with Fargate providing the compute capacity:- Copy and paste the content below in your terminal to create the default provisioner for the cluster:
- Deploy the sample application with 0 count using the command below:
- Now we are ready to observe how Karpenter autoscale and provision EC2 compute capacity needed by pods. Open a second terminal and run the command below to monitor Karpenter:
- In the previous terminal, run the command below to scale the workload and watch the Karpenter controller logs in the other terminal:
- The previous command will launch 5 pods that needs to be scheduled on an EC2 worker node(s). Verify Karpenter has launched the pods on EC2 instance worker node:
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.