This construct adds Karpenter to an existing EKS cluster following the guide located at: https://karpenter.sh/docs/getting-started/. It creates two IAM roles and then adds and installes Karpenter on the EKS cluster. Additionally, it tags subnets with custom tags that are used for instructing Karpenter where to place the nodes.
import { Karpenter } from 'cdk-karpenter'
new Karpenter(scope: Construct, id: string, props: KarpenterProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
KarpenterProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: KarpenterProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
addProvisioner |
addProvisioner adds a provisioner manifest to the cluster. |
public toString(): string
Returns a string representation of this construct.
public addProvisioner(id: string, provisionerSpecs?: ProvisionerSpecs): void
addProvisioner adds a provisioner manifest to the cluster.
- Type: string
must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character.
- Type: ProvisionerSpecs
spec for the Karpenter Provisioner.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { Karpenter } from 'cdk-karpenter'
Karpenter.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
import { BlockDeviceMappingsProps } from 'cdk-karpenter'
const blockDeviceMappingsProps: BlockDeviceMappingsProps = { ... }
Name | Type | Description |
---|---|---|
deviceName |
string |
The device name (for example, /dev/sdh or xvdh). |
ebs |
EbsProps |
No description. |
public readonly deviceName: string;
- Type: string
The device name (for example, /dev/sdh or xvdh).
public readonly ebs: EbsProps;
- Type: EbsProps
Parameters used to automatically set up EBS volumes when the instance is launched.
import { EbsProps } from 'cdk-karpenter'
const ebsProps: EbsProps = { ... }
Name | Type | Description |
---|---|---|
deleteOnTermination |
boolean |
Indicates whether the EBS volume is deleted on instance termination. |
encrypted |
boolean |
Indicates whether the volume should be encrypted. |
iops |
number |
The number of I/O operations per second (IOPS). |
kmsKeyId |
string |
The identifier of the AWS KMS key to use for Amazon EBS encryption. |
snapshotId |
string |
The snapshot ID of the volume to use. |
throughput |
number |
Throughput to provision for a gp3 volume, with a maximum of 1,000 MiB/s. |
volumeSize |
string |
The size of the volume, in GiBs. |
volumeType |
aws-cdk-lib.aws_ec2.EbsDeviceVolumeType |
The volume type. |
public readonly deleteOnTermination: boolean;
- Type: boolean
Indicates whether the EBS volume is deleted on instance termination.
public readonly encrypted: boolean;
- Type: boolean
Indicates whether the volume should be encrypted.
public readonly iops: number;
- Type: number
The number of I/O operations per second (IOPS).
For gp3 , io1 , and io2 volumes, this represents the number of IOPS that are provisioned for the volume. For gp2 volumes, this represents the baseline performance of the volume and the rate at which the volume accumulates I/O credits for bursting.
The following are the supported values for each volume type:
- gp3 : 3,000-16,000 IOPS
- io1 : 100-64,000 IOPS
- io2 : 100-64,000 IOPS
For io1 and io2 volumes, we guarantee 64,000 IOPS only for Instances built on the Nitro System. Other instance families guarantee performance up to 32,000 IOPS.
This parameter is required for io1 and io2 volumes. The default for gp3 volumes is 3,000 IOPS. This parameter is not supported for gp2, st1, sc1, or standard volumes.
public readonly kmsKeyId: string;
- Type: string
The identifier of the AWS KMS key to use for Amazon EBS encryption.
If KmsKeyId is specified, the encrypted state must be true. If the encrypted state is true but you do not specify KmsKeyId, your KMS key for EBS is used.
You can specify the KMS key using key ARN. For example, arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab.
public readonly snapshotId: string;
- Type: string
The snapshot ID of the volume to use.
If you specify both SnapshotId and VolumeSize, VolumeSize must be equal or greater than the size of the snapshot.
public readonly throughput: number;
- Type: number
Throughput to provision for a gp3 volume, with a maximum of 1,000 MiB/s.
Valid Range: Minimum value of 125. Maximum value of 1000.
public readonly volumeSize: string;
- Type: string
The size of the volume, in GiBs.
You must specify either a snapshot ID or a volume size. If you specify a snapshot, the default is the snapshot size. You can specify a volume size that is equal to or larger than the snapshot size.
The following are the supported volumes sizes for each volume type:
- gp2 and gp3 :1-16,384
- io1 and io2 : 4-16,384
- st1 and sc1 : 125-16,384
- standard : 1-1,024
public readonly volumeType: EbsDeviceVolumeType;
- Type: aws-cdk-lib.aws_ec2.EbsDeviceVolumeType
The volume type.
For more information, see Amazon EBS volume types in the Amazon EC2 User Guide. If the volume type is io1 or io2, you must specify the IOPS that the volume supports.
import { KarpenterProps } from 'cdk-karpenter'
const karpenterProps: KarpenterProps = { ... }
Name | Type | Description |
---|---|---|
cluster |
aws-cdk-lib.aws_eks.Cluster |
The EKS cluster on which Karpenter is going to be installed on. |
vpc |
aws-cdk-lib.aws_ec2.IVpc |
VPC. |
subnets |
aws-cdk-lib.aws_ec2.ISubnet[] |
VPC subnets which need to be tagged for Karpenter to find them. |
public readonly cluster: Cluster;
- Type: aws-cdk-lib.aws_eks.Cluster
The EKS cluster on which Karpenter is going to be installed on.
public readonly vpc: IVpc;
- Type: aws-cdk-lib.aws_ec2.IVpc
VPC.
public readonly subnets: ISubnet[];
- Type: aws-cdk-lib.aws_ec2.ISubnet[]
VPC subnets which need to be tagged for Karpenter to find them.
If left blank, private VPC subnets will be used and tagged by default.
import { Limits } from 'cdk-karpenter'
const limits: Limits = { ... }
Name | Type | Description |
---|---|---|
cpu |
string |
CPU limits (i.e. 256). |
mem |
string |
Memory limits (i.e. 1000Gi). |
public readonly cpu: string;
- Type: string
CPU limits (i.e. 256).
public readonly mem: string;
- Type: string
Memory limits (i.e. 1000Gi).
import { ProviderProps } from 'cdk-karpenter'
const providerProps: ProviderProps = { ... }
Name | Type | Description |
---|---|---|
amiFamily |
AMIFamily |
The AMI used when provisioning nodes. |
amiSelector |
{[ key: string ]: string} |
AMISelector is used to configure custom AMIs for Karpenter to use, where the AMIs are discovered through AWS tags, similar to subnetSelector. |
blockDeviceMappings |
BlockDeviceMappingsProps[] |
EBS mapping configuration. |
tags |
{[ key: string ]: string} |
Provisioner level tags. |
public readonly amiFamily: AMIFamily;
- Type: AMIFamily
The AMI used when provisioning nodes.
Based on the value set for amiFamily,Karpenter will automatically query for the appropriate EKS optimized AMI via AWS Systems Manager (SSM).
public readonly amiSelector: {[ key: string ]: string};
- Type: {[ key: string ]: string}
AMISelector is used to configure custom AMIs for Karpenter to use, where the AMIs are discovered through AWS tags, similar to subnetSelector.
This field is optional, and Karpenter will use the latest EKS-optimized AMIs if an amiSelector is not specified.
public readonly blockDeviceMappings: BlockDeviceMappingsProps[];
- Type: BlockDeviceMappingsProps[]
EBS mapping configuration.
public readonly tags: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Provisioner level tags.
Tags will be added to every EC2 instance launched by the provisioner. Provisioner level tags override global Karpenter tags.
import { ProvisionerReqs } from 'cdk-karpenter'
const provisionerReqs: ProvisionerReqs = { ... }
Name | Type | Description |
---|---|---|
archTypes |
ArchType[] |
Architecture type of the node instances. |
capacityTypes |
CapacityType[] |
Capacity type of the node instances. |
instanceTypes |
aws-cdk-lib.aws_ec2.InstanceType[] |
Instance types to be used by the Karpenter Provider. |
restrictInstanceTypes |
aws-cdk-lib.aws_ec2.InstanceType[] |
Instance types to be excluded by the Karpenter Provider. |
public readonly archTypes: ArchType[];
- Type: ArchType[]
Architecture type of the node instances.
public readonly capacityTypes: CapacityType[];
- Type: CapacityType[]
Capacity type of the node instances.
public readonly instanceTypes: InstanceType[];
- Type: aws-cdk-lib.aws_ec2.InstanceType[]
Instance types to be used by the Karpenter Provider.
public readonly restrictInstanceTypes: InstanceType[];
- Type: aws-cdk-lib.aws_ec2.InstanceType[]
Instance types to be excluded by the Karpenter Provider.
import { ProvisionerSpecs } from 'cdk-karpenter'
const provisionerSpecs: ProvisionerSpecs = { ... }
Name | Type | Description |
---|---|---|
requirements |
ProvisionerReqs |
Requirements that constrain the parameters of provisioned nodes. |
consolidation |
boolean |
Enables consolidation which attempts to reduce cluster cost by both removing un-needed nodes and down-sizing those that can't be removed. |
labels |
{[ key: string ]: string} |
Labels are arbitrary key-values that are applied to all nodes. |
limits |
Limits |
CPU and Memory Limits. |
provider |
ProviderProps |
AWS cloud provider configuration. |
startupTaints |
Taints[] |
Provisioned nodes will have these taints, but pods do not need to tolerate these taints to be provisioned by this provisioner. |
taints |
Taints[] |
Provisioned nodes will have these taints. |
ttlSecondsAfterEmpty |
aws-cdk-lib.Duration |
Time in seconds in which nodes will scale down due to low utilization. |
ttlSecondsUntilExpired |
aws-cdk-lib.Duration |
Time in seconds in which nodes will expire and get replaced. |
public readonly requirements: ProvisionerReqs;
- Type: ProvisionerReqs
Requirements that constrain the parameters of provisioned nodes.
These requirements are combined with pod.spec.affinity.nodeAffinity rules.
public readonly consolidation: boolean;
- Type: boolean
Enables consolidation which attempts to reduce cluster cost by both removing un-needed nodes and down-sizing those that can't be removed.
Mutually exclusive with the ttlSecondsAfterEmpty parameter.
public readonly labels: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Labels are arbitrary key-values that are applied to all nodes.
public readonly limits: Limits;
- Type: Limits
CPU and Memory Limits.
Resource limits constrain the total size of the cluster. Limits prevent Karpenter from creating new instances once the limit is exceeded.
public readonly provider: ProviderProps;
- Type: ProviderProps
AWS cloud provider configuration.
public readonly startupTaints: Taints[];
- Type: Taints[]
Provisioned nodes will have these taints, but pods do not need to tolerate these taints to be provisioned by this provisioner.
These taints are expected to be temporary and some other entity (e.g. a DaemonSet) is responsible for removing the taint after it has finished initializing the node.
public readonly taints: Taints[];
- Type: Taints[]
Provisioned nodes will have these taints.
Taints may prevent pods from scheduling if they are not tolerated.
public readonly ttlSecondsAfterEmpty: Duration;
- Type: aws-cdk-lib.Duration
Time in seconds in which nodes will scale down due to low utilization.
If omitted, the feature is disabled, nodes will never scale down due to low utilization. Mutually exclusive with the consolidation parameter.
public readonly ttlSecondsUntilExpired: Duration;
- Type: aws-cdk-lib.Duration
Time in seconds in which nodes will expire and get replaced.
If omitted, the feature is disabled and nodes will never expire. i.e. Duration.days(7)
import { Taints } from 'cdk-karpenter'
const taints: Taints = { ... }
Name | Type | Description |
---|---|---|
effect |
string |
Effect. |
key |
string |
Key. |
operator |
string |
Operator. |
value |
string |
Value. |
public readonly effect: string;
- Type: string
Effect.
public readonly key: string;
- Type: string
Key.
public readonly operator: string;
- Type: string
Operator.
public readonly value: string;
- Type: string
Value.
Name | Description |
---|---|
AL2 |
Amazon Linux 2 AMI family Note: If a custom launch template is specified, then the AMI value in the launch template is used rather than the amiFamily value. |
BOTTLEROCKET |
Bottlerocket AMI family. |
UBUNTU |
Ubuntu AMI family. |
CUSTOM |
Custom AMI family. |
Amazon Linux 2 AMI family Note: If a custom launch template is specified, then the AMI value in the launch template is used rather than the amiFamily value.
Bottlerocket AMI family.
Ubuntu AMI family.
Custom AMI family.
Name | Description |
---|---|
ARM64 |
ARM based instances. |
AMD64 |
x86 based instances. |
ARM based instances.
x86 based instances.
Name | Description |
---|---|
SPOT |
Spot capacity. |
ON_DEMAND |
On demand capacity. |
Spot capacity.
On demand capacity.