Prerequisites
Before you begin you must have:- AWS CLI configured
kubectl,talosctl, andhelminstalled
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:- Click Download Installation Media in the Omni dashboard.
- Select the AWS AMI for your architecture.
- Add a Machine User Label that identifies the machine’s role. For example, for a control plane machine:
role:karpenter-controlplane-machine. - Click Download to generate the AMI file.
- Upload the AMI file to your AWS account. Follow the instructions in the Create Your Own AMIsguide.
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:- Create a file named
controlplane-machine-class.yaml:
karpenter-controlplane Machine Class that matches machines using the control plane label you added to the AMI ( e.g., role:karpenter-controlplane-machine).
- Apply it:
- Verify it exists:
3.2: Worker Machine Class
Repeat the process for the worker machines:- Create a file named
worker-machine-class.yaml:
- Apply it:
- Verify:
Step 4: Create a cluster
Next, create a cluster using cluster templates:- Create a file named
cluster-template.yamland paste the following YAML, updating the placeholders as needed:
<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.
- Apply the
cluster-template.yamlto create the cluster:
- Once your cluster is running, download and export its
kubeconfigso you can interact with it. Replace<cluster-name>with the name of your cluster:
- 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 withAccessDenied 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:7.2: Create an instance profile and IAM role
Create a new instance profile and IAM role for the Karpenter node: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: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:Step 10: Create an EC2NodeClass
TheEC2NodeClass 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
TheNodePool 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:Step 13: Trigger autoscaling
Increase the number of replicas to create pending pods and trigger Karpenter to provision new nodes:Cleanup
Delete the resources created in this guide:- First, remove the demo deployment and Karpenter CRDs:
- Uninstall Karpenter:
- Delete the interuption queue:
- Detach and delete the IAM policy:
- Remove and delete the instance profile and role: