Blog
AWS
Cloud
DevOps
Kubernetes
8
minutes

Autoscaling Amazon EKS with Karpenter: A Step-by-Step Guide

Managing resource scaling in EKS clusters can quickly become complex, especially with fluctuating workloads. Traditional autoscaling solutions often require predefined configurations, which can lead to inefficiencies and unnecessary costs. This is where Karpenter comes in—a powerful, open-source project designed to dynamically manage and scale nodes in response to real-time application demands. By automatically provisioning resources exactly when they’re needed, Karpenter offers a more streamlined, efficient approach to scaling. Let's discuss Karpenter’s standout features and benefits, and we'll walk you through a step-by-step guide to deploying it on your EKS cluster.
Morgan Perry
Co-founder
Summary
Twitter icon
linkedin icon

What is Karpenter?

Karpenter is an open-source, dynamic capacity provisioner for Kubernetes clusters that simplifies and optimizes resource management. As a sophisticated tool, it intelligently provisions and scales nodes based on real-time application demands and ensures efficient use of resources. Karpenter eliminates the need for pre-defined scaling policies, which makes it ideal for dynamic and unpredictable workloads. Let’s go through some of its powerful features in detail.

Key Features

Intelligent Node Provisioning and Scaling

Karpenter dynamically provisions nodes in response to workload requirements, optimizing resource usage and reducing latency. It scales clusters up or down based on actual demand to ensure efficient resource allocation.

Compatibility with Diverse EC2 Instance Types

Karpenter supports a wide range of EC2 instance types, enabling the use of cost-effective Spot Instances. This flexibility allows users to mix and match instances to optimize performance and cost.

Adaptability to Real-Time Workload Demands

Karpenter adjusts to changing workload demands in real-time. This ensures that the applications have the necessary resources when they need them. This adaptability minimizes over-provisioning and under-provisioning, enhancing overall efficiency.

Why Choose Karpenter Over Traditional Autoscaling Solutions?

Karpenter offers several advantages over traditional autoscaling solutions like Cluster Autoscaler and Managed Node Groups, which makes it a superior choice for modern Kubernetes environments. Cluster Autoscaler and Managed Node Groups require pre-defined node groups and scaling policies, which can be inflexible and inefficient for dynamic workloads. In contrast, Karpenter's on-demand scaling approach eliminates the need for predefined configurations, providing greater flexibility.

Benefits of Karpenter

  • No Need for Pre-Defined Node Groups: Karpenter dynamically provisions nodes based on real-time demand, removing the need for predefined node groups. This flexibility simplifies cluster management and improves resource utilization.
  • Decoupled from Specific EKS Versions, Offering Flexibility: Karpenter operates independently of specific EKS versions, allowing it to be used across different Kubernetes environments without compatibility issues. This decoupling enhances deployment flexibility and simplifies upgrades.
  • Saving up to 60% on EC2 Costs Compared to Standard Autoscaling Solutions: By using cost-effective EC2 instance types, including Spot Instances, Karpenter significantly reduces infrastructure costs upto 60%. Its intelligent provisioning and scaling capabilities ensure optimal resource utilization, leading to substantial cost savings.
Advantages of Karpenter | Source: https://amnic.com/blogs/unlocking-full-potential-of-aws-with-karpenter-2
For a deeper comparison of the advantages Karpenter offers over Cluster Autoscaler in Kubernetes environments, check out our article on Kubernetes Cluster Autoscaler vs. Karpenter to explore the differences in scaling behavior, configuration requirements, and cost implications.

Setting Up Karpenter on Amazon EKS

Prerequisites:

  • Access to an AWS EKS cluster.
  • Installed and configured tools (e.g., kubectl, helm, AWS CLI).

Installation Steps:

1. Create an IAM Role for Karpenter with Necessary Permissions:

Begin by creating an IAM role that Karpenter will use to interact with your EKS cluster and other AWS services. This role needs permissions for autoscaling, EC2 instance management, and other related tasks.

aws iam create-role --role-name KarpenterRole --assume-role-policy-document file://trust-policy.json
aws iam attach-role-policy --role-name KarpenterRole --policy-arn arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
aws iam attach-role-policy --role-name KarpenterRole --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess

2. Prepare a values.yaml Configuration File for Helm Installation:

Create a values.yaml file with the necessary configuration settings for Karpenter. This file defines parameters like instance types, scaling policies, and other resource specifications.

serviceAccount:
create: true
name: karpenter
controller:
clusterName: my-cluster
clusterEndpoint: https://1234567890.gr7.us-east-1.eks.amazonaws.com
aws:
defaultInstanceProfile: KarpenterInstanceProfile

3. Deploy Karpenter Using Helm:

Use Helm to deploy Karpenter with the prepared values.yaml file. This step installs Karpenter and applies the configuration.

helm repo add karpenter https://charts.karpenter.shhelm repo updatehelm install karpenter karpenter/karpenter -f values.yaml

4. Verify the Deployment:

Check the status of the Karpenter deployment to ensure it is running correctly and interacting with your EKS cluster.

kubectl get pods -n karpenterkubectl logs -f deployment/karpenter-controller -n karpenter

Configuring Karpenter for Dynamic Provisioning

To set up Karpenter on EKS for dynamic provisioning, a critical step is defining a Provisioner. The Provisioner is a Kubernetes custom resource that allows you to specify how Karpenter should allocate resources in your cluster. With the Provisioner, you can define parameters such as instance types, node architecture, capacity type, and settings for node termination, enabling tailored resource allocation based on your workload needs.

Karpenter dynamically provisions nodes for unscheduled Kubernetes pods | Source: https://aws.amazon.com/blogs/aws/introducing-karpenter-an-open-source-high-performance-kubernetes-cluster-autoscaler/

Define a Provisioner for Customized Resource Allocation

  1. Specify Instance Requirements: In your Provisioner configuration, you can list specific EC2 instance types or instance families. This ensures that Karpenter only provisions nodes compatible with your workload. This flexibility allows you to optimize cost and performance by choosing instance types that match your application’s requirements, such as memory, CPU, or GPU capabilities.
  2. Define Architecture: Karpenter supports multiple CPU architectures, such as x86 and ARM (Graviton). You can specify the desired architecture in your Provisioner settings to ensure that nodes are provisioned with compatible architectures for your workloads.
  3. Select Capacity Type: For cost-efficiency, you can specify the capacity type to use either On-Demand or Spot Instances. Spot Instances provide substantial cost savings but come with the risk of interruptions, making them suitable for fault-tolerant applications. By balancing Spot and On-Demand Instances, you can optimize costs without sacrificing reliability.
  4. Include TTL Settings for Unused Nodes: Karpenter allows you to set Time-to-Live (TTL) values for unused nodes. This setting ensures that if a node is no longer needed (for example, if workloads are completed or scaled down), it will be automatically terminated after a specified period, minimizing idle costs and maximizing resource efficiency.

Here’s a sample YAML configuration to define a Provisioner for Karpenter:

apiVersion: karpenter.sh/v1alpha5kind: Provisionermetadata:  name: defaultspec:  requirements:    - key: "node.kubernetes.io/instance-type"      operator: In      values: ["m5.large", "m5.xlarge"]  # Define allowed instance types    - key: "kubernetes.io/arch"      operator: In      values: ["x86_64"]  # Define architecture (e.g., x86 or ARM)  provider:    capacityType: "SPOT"  # Specify capacity type (SPOT or ON-DEMAND)  ttlSecondsAfterEmpty: 300  # Set TTL for unused nodes (e.g., 5 minutes)

Easily Enable Karpenter with Qovery on AWS

What Qovery Does?

Qovery is a DevOps automatiob Platform that simplifies application deployment and management on AWS EKS. It automates infrastructure provisioning, scaling, and application deployment so that developers can focus on building applications without worrying about complex backend operations. By integrating Karpenter, Qovery enables seamless, intelligent scaling and resource management so that your applications can run efficiently and cost-effectively.

Benefits of Qovery-Karpenter Integration

  1. Optimized Resource Utilization
    - Dynamic Scaling: Karpenter, when integrated with Qovery, dynamically adjusts resource allocation based on actual application demands. This makes sure you’re only using what you need.
    - Avoids Over-Provisioning: Prevents excess resource allocation, so idle resources aren’t sitting unused, saving costs and improving efficiency.
    - Prevents Under-Provisioning: Ensures sufficient resources are always available for peak performance, even during high demand, avoiding slowdowns and performance drops.
  2. Cost Savings
    - Leverages Spot Instances: Spot Instances are significantly more affordable than On-Demand Instances, and Karpenter can prioritize these to reduce overall costs. Use spot instances with caution if you are in a production environment and need to use the instances for mission-critical tasks.
    - Balances with On-Demand Instances: Qovery and Karpenter together balance Spot and On-Demand Instances based on application tolerance, so you save costs while maintaining reliability at the same time.
    - Potential 60% Cost Reduction: By maximizing Spot Instance use, the integration can cut EC2 costs by up to 60%. This makes it ideal for organizations looking to maximize cloud budget efficiency.
  3. Simplified Operations
    - Easy Integration: Qovery automates Karpenter’s setup to minimize the manual input needed to activate and manage autoscaling.
    - Streamlined Configuration: Activating Karpenter requires just a few configuration parameters for quick setup without complex adjustments.
    - Reduced Operational Overhead: With Karpenter’s scaling functions automated, teams can focus on development and application improvement, rather than on constant infrastructure maintenance.

Quick Steps to Activate Karpenter via Qovery

  1. Access Advanced Settings: Log in to your Qovery console, navigate to your AWS EKS cluster settings, and go to the "Advanced Settings" section.
  2. Enable Karpenter: Set the aws.karpenter.enable parameter to true to activate Karpenter in your cluster.
  3. Optionally Enable Spot Instances: To maximize cost savings, set aws.karpenter.enable_spot to true to allow the use of Spot Instances.
  4. Apply Changes: Save these settings and redeploy your cluster to activate the configurations.

Conclusion

Karpenter empowers you to optimize resource utilization and reduce costs in your EKS clusters by dynamically provisioning nodes based on real-time demand. With Qovery, you can seamlessly integrate Karpenter into your Kubernetes workflow, simplifying the process and maximizing its benefits. By taking advantage of this powerful combination, you can achieve a more efficient and cost-effective EKS environment.

Qovery offers an all-in-one platform that helps startups and growing organizations automate every aspect of their DevOps lifecycle. With Qovery, you can automate infrastructure provisioning, CI/CD pipelines, security checks, and cloud scaling—without the need for deep DevOps expertise.

Start your automation journey with Qovery today!

Share on :
Twitter icon
linkedin icon
Ready to rethink the way you do DevOps?
Qovery is a DevOps automation platform that enables organizations to deliver faster and focus on creating great products.
Book a demo

Suggested articles

SecurityAndCompliance
DevSecOps
 minutes
Qovery Achieves SOC 2 Type II Compliance

Qovery is officially SOC 2 Type II compliant with an Unqualified Opinion. Get the highest assurance of continuously verified security controls for enterprise-grade application deployments and simplify due diligence.

Pierre Mavro
CTO & Co-founder
Product
Observability
 minutes
Troubleshoot Faster with the New Log Search and Filtering in Qovery Observe

Following the launch of Qovery Observe, we’re progressively adding new capabilities to help you better monitor, debug, and understand your applications. Today, we’re excited to announce a major improvement to the Logs experience: you can now search and filter directly within your application logs.

Alessandro Carrano
Lead Product Manager
Platform Engineering
DevOps
Terraform
7
 minutes
Top 5 Crossplane Alternatives & Competitors

Go beyond Crossplane. Discover Qovery, the #1 DevOps automation tool, and 4 other IaC alternatives (Terraform, Pulumi) for simplified multi-cloud infrastructure management and deployment.

Morgan Perry
Co-founder
AWS
Platform Engineering
DevOps
9
 minutes
10 Best AWS ECS (Elastic Container Service) Alternatives

Compare the top 10 AWS ECS alternatives, including Qovery, Docker, EKS, and GKE. Find the best solution to simplify Kubernetes, automate DevOps, and achieve multi-cloud container deployment.

Morgan Perry
Co-founder
Platform Engineering
AWS
Kubernetes
DevOps
9
 minutes
10 Best EKS Alternatives: Simplifying Kubernetes for Modern Development

Compare the 10 best EKS alternatives for Kubernetes, including Qovery (IDP), GKE, DOKS, and OpenShift. Simplify operations, reduce costs, and accelerate deployment.

Morgan Perry
Co-founder
DevOps
Kubernetes
Platform Engineering
15
 minutes
Top 10 Openshift Alternatives & Competitors

Because various organizations need cloud application and service management that offers different levels of simplicity, cost-effectiveness, or feature sets than OpenShift, this article will review its top alternatives to help readers make an informed decision aligned with their specific infrastructure needs.

Morgan Perry
Co-founder
AI
Infrastructure Management
Product
5
 minutes
GPU workloads on EKS just got way simpler with Qovery

Running GPU workloads on EKS has never been easy, until now. With Qovery’s latest update, you can enable GPU nodes, configure GPU access, and optimize costs automatically, all without writing a single line of YAML or touching Helm charts. Qovery now handles everything behind the scenes so you can focus entirely on your applications.

Alessandro Carrano
Lead Product Manager
Kubernetes
 minutes
Kubernetes Deployment Strategies: Pros, Cons & Use Cases

Master Kubernetes deployment strategies: Rolling Update, Recreate, Blue/Green, and Canary. Learn the pros, cons, and use cases to choose the right strategy based on your uptime, risk tolerance, and resources. Simplify complex rollouts with automation.

Mélanie Dallé
Senior Marketing Manager

It’s time to rethink
the way you do DevOps

Say goodbye to DevOps overhead. Qovery makes infrastructure effortless, giving you full control without the trouble.