Skip to main content
Karpenter is a high-performance Kubernetes autoscaler that launches and terminates nodes in response to real-time workload demand. This guide walks you through integrating Karpenter with Talos Linux clusters running on AWS and managed through Omni.

Prerequisites

Before you begin you must have:
  • AWS CLI configured
  • kubectl, talosctl, and helm installed

Step 1: Create your Talos AMIs.

You will need two AMIs: one for your control plane machines and one for your worker machines. To create each AMI:
  1. Click Download Installation Media in the Omni dashboard.
  2. Select the AWS AMI for your architecture.
  3. Add a Machine User Label that identifies the machine’s role. For example, for a control plane machine: role:karpenter-controlplane-machine.
  4. Click Download to generate the AMI file.
  5. Upload the AMI file to your AWS account. Follow the instructions in the Create Your Own AMIsguide.
Repeat the process to create the worker AMI, but use a worker-specific label (e.g. role:karpenter-worker-machine).
Note: The AMI’s final name in AWS will match the filename you upload to S3. You can use naming conventions to clearly distinguish between your control plane and worker AMIs.

Step 2: Create your machines using the AMIs

Use the control plane AMI to create your control plane machines.
Using an odd number of control plane nodes help etcd maintain quorum reliably. For high availability, we recommend creating three control plane nodes.

Step 3: Create Machine Classes

Machine Classes group machines by labels and act as the pool description for clusters. You’ll create two Machine Classes:
  • one for control plane machines
  • one for worker machines

3.1: Control plane Machine Class

To create a machine class for your control plane machines:
  1. Create a file named controlplane-machine-class.yaml:
This creates a karpenter-controlplane Machine Class that matches machines using the control plane label you added to the AMI ( e.g., role:karpenter-controlplane-machine).
  1. Apply it:
  1. Verify it exists:

3.2: Worker Machine Class

Repeat the process for the worker machines:
  1. Create a file named worker-machine-class.yaml:
  1. Apply it:
  1. Verify:

Step 4: Create a cluster

Next, create a cluster using cluster templates:
  1. Create a file named cluster-template.yaml and paste the following YAML, updating the placeholders as needed:
This template creates a cluster and assigns machines to the appropriate Machine Classes. Replace the following placeholders:
  • <cluster-name>— the name you want to give your cluster
  • <name of your control plane machine class>— the Machine Class for your control plane nodes.
  • <number of control plane machines>— how many control plane nodes your cluster should have.
  • <name of your worker plane machine class>— the Machine Class for your worker nodes.
  1. Apply the cluster-template.yaml to create the cluster:
  1. Once your cluster is running, download and export its kubeconfig so you can interact with it. Replace <cluster-name> with the name of your cluster:
  1. Verify that all machines are running:

Step 5: Define all variables

Set the environment variables you will use throughout this guide:

Step 6: Tag subnets and security groups for Karpenter discovery

Karpenter can only launch nodes into subnets and security groups that you explicitly mark for discovery.
You do this by adding a karpenter.sh/discovery tag to each resource.
Run the following commands to tag your subnets and security groups:

Step 7: Fix IAM permissions on the Karpenter node

Karpenter uses the IAM role of the node where the Karpenter controller pod runs. If the node running the Karpenter pod has no IAM instance profile (which is common when using Omni), Karpenter will fail with AccessDenied errors. This step ensures your Karpenter nodes have the correct AWS permissions.

7.1: Identify the Karpenter node

First, retrieve your control plane nodes and their IP addresses:
Pick the node where Karpenter will run, then set its name and IP address as environment variables:
Next, find the EC2 instance ID that corresponds to that IP:

7.2: Create an instance profile and IAM role

Create a new instance profile and IAM role for the Karpenter node:
Next, attach the role to the instance profile:
Then, associate the instance profile with the worker EC2 instance:
Export the values for later steps:

7.3: Attach required IAM permissions

Next, attach the required policies that grant Karpenter the permissions to launch, tag, and terminate EC2 instances for this cluster:
Then attach these policies to the Karpenter role:

Step 8: Create Karpenter interruption queue

Karpenter can respond to AWS node interruption events (such as maintenance, spot interruptions, or scheduled shutdowns). To enable this, create a simple SQS queue that Karpenter can watch. When AWS publishes an interruption event, Karpenter drains and replaces the node before it terminates.
When Karpenter (or AWS) terminates an EC2 instance, the matching node is removed from Kubernetes, but the Machine is not deleted automatically in Omni.You may still see terminated machines listed in the Omni UI and need to clean them up manually.

Step 9: Install Karpenter via Helm

At this point, Karpenter has everything it needs, the cluster endpoint and the required IAM permissions, to provision new machines. Install it using Helm:
Add the topology spread label required by Karpenter:
Confirm that the controller is running:

Step 10: Create an EC2NodeClass

The EC2NodeClass tells Karpenter how to launch Talos worker machines: which AMI to use, which subnets and security groups to join, and which IAM instance profile to attach.

Step 11: Create a NodePool

The NodePool defines what Karpenter is allowed to provision. This includes limits, disruption behavior, labels, and instance-type requirements.

Step 12: Deploy a workload that triggers autoscaling

Now deploy a simple workload that Karpenter can scale against:
Check workload exists:

Step 13: Trigger autoscaling

Increase the number of replicas to create pending pods and trigger Karpenter to provision new nodes:
Watch autoscaling:
You can also watch the new machines appear in the Omni dashboard as Karpenter provisions them and they join the cluster.

Cleanup

Delete the resources created in this guide:
  1. First, remove the demo deployment and Karpenter CRDs:
  1. Uninstall Karpenter:
  1. Delete the interuption queue:
  1. Detach and delete the IAM policy:
  1. Remove and delete the instance profile and role: