Skip to main content

cdk-eks-karpenter

This construct configures the necessary dependencies and installs Karpenter on an EKS cluster managed by AWS CDK.

Prerequisites

Usage with EC2 Spot Capacity

If you have not used EC2 spot in your AWS account before, follow the instructions here to create the service linked role in your account allowing Karpenter to provision EC2 Spot Capacity.

Using

In your CDK project, initialize a new Karpenter construct for your EKS cluster, like this:

const cluster = new Cluster(this, 'testCluster', {
  vpc: vpc,
  role: clusterRole,
  version: KubernetesVersion.V1_27,
  defaultCapacity: 1
});

const karpenter = new Karpenter(this, 'Karpenter', {
  cluster: cluster,
  namespace: "kube-system"
});

This will install and configure Karpenter in your cluster. To have Karpenter do something useful, you also need to create an EC2NodeClass and an NodePool, for a more complete example, see test/integ.karpenter.ts.

Known issues

It is now a best practice to install Karpenter into the kube-system namespace:

Kapenter CRD webhooks have 'kube-system' hard-coded into them, and do not work in other namespaces (such as 'karpenter')

Versions earlier than v0.6.1 fails to install

As of aws/karpenter#1145 the Karpenter Helm chart is refactored to specify clusterEndpoint and clusterName on the root level of the chart values, previously these values was specified under the key controller.

Testing

This construct adds a custom task to projen, so you can test a full deployment of an EKS cluster with Karpenter installed as specified in test/integ.karpenter.ts by running the following:

export CDK_DEFAULT_REGION=<aws region>
export CDK_DEFAULT_ACCOUNT=<account id>
npx projen test:deploy

As the above will create a cluster without EC2 capacity, with CoreDNS and Karpenter running as Fargate pods, you can test out the functionality of Karpenter by deploying an inflation deployment, which will spin up a number of pods that will trigger Karpenter creation of worker nodes:

kubectl apply -f test/inflater-deployment.yml

You can clean things up by deleting the deployment and the CDK test stack:

kubectl delete -f test/inflater-deployment.yml
npx projen test:destroy

FAQ

I'm not able to launch spot instances

  1. Ensure you have the appropriate linked role available in your account, for more details, see the karpenter documentation

Metadata

Release files for cdk-eks-karpenter 1.0.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdk-eks-karpenter 1.0.27
File Size Uploaded
cdk_eks_karpenter-1.0.27.tar.gz 85.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cdk-eks-karpenter 1.0.27
File Interpreter ABI Platform
cdk_eks_karpenter-1.0.27-py3-none-any.whl Python 3 none any Details

Total release size: 170.0 kB

Release files / cdk_eks_karpenter-1.0.27.tar.gz

Download URL cdk_eks_karpenter-1.0.27.tar.gz
Size 85.7 kB
Tags Source
SHA-256 checksum
How to use checksums
50200808dda14983882554aa6bad7d3451d17d4f783b6ea7228f125fbe3c454a
BLAKE2b-256 checksum
How to use checksums
ac36c463bdf110837bfd7fb991fa92e87fbdca350fca24b6f7f7cd12490fe450
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.14.6

Release files / cdk_eks_karpenter-1.0.27-py3-none-any.whl

Download URL cdk_eks_karpenter-1.0.27-py3-none-any.whl
Size 84.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28f4e64b52e3a5929c45eaec98aa727fa7b2ee2230e4571729dfe8ae1b40d46d
BLAKE2b-256 checksum
How to use checksums
988f274f10bdd71b22b9d60f97330cfae2e6ce04a53febe7f4ff85e14d3c9812
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

1.0.27 This release

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.11

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.41

2 release files

0.0.40

2 release files

0.0.39

2 release files

0.0.38

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.30

2 release files

0.0.28

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.16

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page