Skip to main content

CDK construct library that allows you install Karpenter in an AWS EKS cluster

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk_eks_karpenter-1.0.22.tar.gz (85.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdk_eks_karpenter-1.0.22-py3-none-any.whl (84.3 kB view details)

Uploaded Python 3

File details

Details for the file cdk_eks_karpenter-1.0.22.tar.gz.

File metadata

  • Download URL: cdk_eks_karpenter-1.0.22.tar.gz
  • Upload date:
  • Size: 85.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.14.3

File hashes

Hashes for cdk_eks_karpenter-1.0.22.tar.gz
Algorithm Hash digest
SHA256 6dff5c81304f30b991ee4cd46ca96187719625f16b4984534dd16cd672458743
MD5 989cc799ea8bce78fb3c200c26482e93
BLAKE2b-256 20b464c90abb5c001f69bd7ef0c1c9fc78d14b4fa972f6092f9ce01e1c1511e4

See more details on using hashes here.

File details

Details for the file cdk_eks_karpenter-1.0.22-py3-none-any.whl.

File metadata

File hashes

Hashes for cdk_eks_karpenter-1.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 289e52d3892d2a1134eaaf66c3917c30daf4d9165d33b0c1d67f8f88642363d8
MD5 2b1cedee7755aab626ded20f3d7cf4c8
BLAKE2b-256 b2716c38e43e34737efefc6546b0ee33db4be4ce7f572c0fbe0f1d791a6d02d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page