Skip to content

Commit 6aa1b1b

Browse files
authored
feat(eks): support Bottlerocket Nvidia AMIs (#28287)
Adds support for `BOTTLEROCKET_ARM_64_NVIDIA` and `BOTTLEROCKET_x86_64_NVIDIA` AMI types. Closes #28241. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 020bf18 commit 6aa1b1b

File tree

3 files changed

+71
-11
lines changed

3 files changed

+71
-11
lines changed

packages/aws-cdk-lib/aws-eks/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,17 @@ For example, if the Amazon EKS cluster version is `1.17`, the Bottlerocket AMI v
558558
559559
Please note Bottlerocket does not allow to customize bootstrap options and `bootstrapOptions` properties is not supported when you create the `Bottlerocket` capacity.
560560

561+
To create a Bottlerocket managed nodegroup with Nvidia-based EC2 instance types use the `BOTTLEROCKET_X86_64_NVIDIA` or
562+
`BOTTLEROCKET_ARM_64_NVIDIA` AMIs:
563+
564+
```ts
565+
declare const cluster: eks.Cluster;
566+
cluster.addNodegroupCapacity('BottlerocketNvidiaNG', {
567+
amiType: eks.NodegroupAmiType.BOTTLEROCKET_X86_64_NVIDIA,
568+
instanceTypes: [new ec2.InstanceType('g4dn.xlarge')],
569+
});
570+
```
571+
561572
For more details about Bottlerocket, see [Bottlerocket FAQs](https://aws.amazon.com/bottlerocket/faqs/) and [Bottlerocket Open Source Blog](https://aws.amazon.com/blogs/opensource/announcing-the-general-availability-of-bottlerocket-an-open-source-linux-distribution-purpose-built-to-run-containers/).
562573

563574
### Endpoint Access

packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts

+21-8
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ export interface INodegroup extends IResource {
1717
}
1818

1919
/**
20-
* The AMI type for your node group. GPU instance types should use the `AL2_x86_64_GPU` AMI type, which uses the
21-
* Amazon EKS-optimized Linux AMI with GPU support. Non-GPU instances should use the `AL2_x86_64` AMI type, which
22-
* uses the Amazon EKS-optimized Linux AMI.
20+
* The AMI type for your node group.
21+
*
22+
* GPU instance types should use the `AL2_x86_64_GPU` AMI type, which uses the
23+
* Amazon EKS-optimized Linux AMI with GPU support or the `BOTTLEROCKET_ARM_64_NVIDIA` or `BOTTLEROCKET_X86_64_NVIDIA`
24+
* AMI types, which uses the Amazon EKS-optimized Linux AMI with Nvidia-GPU support.
25+
*
26+
* Non-GPU instances should use the `AL2_x86_64` AMI type, which uses the Amazon EKS-optimized Linux AMI.
2327
*/
2428
export enum NodegroupAmiType {
2529
/**
@@ -35,13 +39,21 @@ export enum NodegroupAmiType {
3539
*/
3640
AL2_ARM_64 = 'AL2_ARM_64',
3741
/**
38-
* Bottlerocket Linux(ARM-64)
42+
* Bottlerocket Linux (ARM-64)
3943
*/
4044
BOTTLEROCKET_ARM_64 = 'BOTTLEROCKET_ARM_64',
4145
/**
42-
* Bottlerocket(x86-64)
46+
* Bottlerocket (x86-64)
4347
*/
4448
BOTTLEROCKET_X86_64 = 'BOTTLEROCKET_x86_64',
49+
/**
50+
* Bottlerocket Linux with Nvidia-GPU support (ARM-64)
51+
*/
52+
BOTTLEROCKET_ARM_64_NVIDIA = 'BOTTLEROCKET_ARM_64_NVIDIA',
53+
/**
54+
* Bottlerocket with Nvidia-GPU support (x86-64)
55+
*/
56+
BOTTLEROCKET_X86_64_NVIDIA = 'BOTTLEROCKET_x86_64_NVIDIA',
4557
/**
4658
* Windows Core 2019 (x86-64)
4759
*/
@@ -215,7 +227,7 @@ export interface NodegroupOptions {
215227
/**
216228
* The instance type to use for your node group. Currently, you can specify a single instance type for a node group.
217229
* The default value for this parameter is `t3.medium`. If you choose a GPU instance type, be sure to specify the
218-
* `AL2_x86_64_GPU` with the amiType parameter.
230+
* `AL2_x86_64_GPU`, `BOTTLEROCKET_ARM_64_NVIDIA`, or `BOTTLEROCKET_x86_64_NVIDIA` with the amiType parameter.
219231
*
220232
* @default t3.medium
221233
* @deprecated Use `instanceTypes` instead.
@@ -409,7 +421,7 @@ export class Nodegroup extends Resource implements INodegroup {
409421

410422
// if the user explicitly configured an ami type, make sure it's included in the possibleAmiTypes
411423
if (props.amiType && !possibleAmiTypes.includes(props.amiType)) {
412-
throw new Error(`The specified AMI does not match the instance types architecture, either specify one of ${possibleAmiTypes} or don't specify any`);
424+
throw new Error(`The specified AMI does not match the instance types architecture, either specify one of ${possibleAmiTypes.join(', ')} or don't specify any`);
413425
}
414426

415427
//if the user explicitly configured a Windows ami type, make sure the instanceType is allowed
@@ -550,7 +562,8 @@ const x8664AmiTypes: NodegroupAmiType[] = [NodegroupAmiType.AL2_X86_64, Nodegrou
550562
const windowsAmiTypes: NodegroupAmiType[] = [NodegroupAmiType.WINDOWS_CORE_2019_X86_64,
551563
NodegroupAmiType.WINDOWS_CORE_2022_X86_64, NodegroupAmiType.WINDOWS_FULL_2019_X86_64,
552564
NodegroupAmiType.WINDOWS_FULL_2022_X86_64];
553-
const gpuAmiTypes: NodegroupAmiType[] = [NodegroupAmiType.AL2_X86_64_GPU];
565+
const gpuAmiTypes: NodegroupAmiType[] = [NodegroupAmiType.AL2_X86_64_GPU,
566+
NodegroupAmiType.BOTTLEROCKET_X86_64_NVIDIA, NodegroupAmiType.BOTTLEROCKET_ARM_64_NVIDIA];
554567

555568
/**
556569
* This function check if the instanceType is GPU instance.

packages/aws-cdk-lib/aws-eks/test/nodegroup.test.ts

+39-3
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ describe('node group', () => {
558558
new ec2.InstanceType('p3.large'),
559559
new ec2.InstanceType('g3.large'),
560560
],
561-
})).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64_GPU or don't specify any/);
561+
})).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64_GPU, BOTTLEROCKET_x86_64_NVIDIA, BOTTLEROCKET_ARM_64_NVIDIA or don't specify any/);
562562
});
563563

564564
/**
@@ -580,7 +580,7 @@ describe('node group', () => {
580580
new ec2.InstanceType('c5.large'),
581581
new ec2.InstanceType('m5.large'),
582582
],
583-
})).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64,BOTTLEROCKET_x86_64,WINDOWS_CORE_2019_x86_64,WINDOWS_CORE_2022_x86_64,WINDOWS_FULL_2019_x86_64,WINDOWS_FULL_2022_x86_64 or don't specify any/);
583+
})).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64, BOTTLEROCKET_x86_64, WINDOWS_CORE_2019_x86_64, WINDOWS_CORE_2022_x86_64, WINDOWS_FULL_2019_x86_64, WINDOWS_FULL_2022_x86_64 or don't specify any/);
584584
});
585585

586586
test('throws when AmiType is Windows and forbidden instanceType is selected', () => {
@@ -619,7 +619,43 @@ describe('node group', () => {
619619
new ec2.InstanceType('c5.large'),
620620
new ec2.InstanceType('m5.large'),
621621
],
622-
})).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64,BOTTLEROCKET_x86_64,WINDOWS_CORE_2019_x86_64,WINDOWS_CORE_2022_x86_64,WINDOWS_FULL_2019_x86_64,WINDOWS_FULL_2022_x86_64 or don't specify any/);
622+
})).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64, BOTTLEROCKET_x86_64, WINDOWS_CORE_2019_x86_64, WINDOWS_CORE_2022_x86_64, WINDOWS_FULL_2019_x86_64, WINDOWS_FULL_2022_x86_64 or don't specify any/);
623+
});
624+
625+
test('throws when LaunchTemplate is undefined, amiType is BOTTLEROCKET_ARM_64_NVIDIA and instanceTypes are not GPU', () => {
626+
// GIVEN
627+
const { stack, vpc } = testFixture();
628+
const cluster = new eks.Cluster(stack, 'Cluster', {
629+
vpc,
630+
defaultCapacity: 0,
631+
version: CLUSTER_VERSION,
632+
});
633+
// THEN
634+
expect(() => cluster.addNodegroupCapacity('ng', {
635+
amiType: NodegroupAmiType.BOTTLEROCKET_ARM_64_NVIDIA,
636+
instanceTypes: [
637+
new ec2.InstanceType('c5.large'),
638+
new ec2.InstanceType('m5.large'),
639+
],
640+
})).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64, BOTTLEROCKET_x86_64, WINDOWS_CORE_2019_x86_64, WINDOWS_CORE_2022_x86_64, WINDOWS_FULL_2019_x86_64, WINDOWS_FULL_2022_x86_64 or don't specify any/);
641+
});
642+
643+
test('throws when LaunchTemplate is undefined, amiType is BOTTLEROCKET_X86_64_NVIDIA and instanceTypes are not GPU', () => {
644+
// GIVEN
645+
const { stack, vpc } = testFixture();
646+
const cluster = new eks.Cluster(stack, 'Cluster', {
647+
vpc,
648+
defaultCapacity: 0,
649+
version: CLUSTER_VERSION,
650+
});
651+
// THEN
652+
expect(() => cluster.addNodegroupCapacity('ng', {
653+
amiType: NodegroupAmiType.BOTTLEROCKET_X86_64_NVIDIA,
654+
instanceTypes: [
655+
new ec2.InstanceType('c5.large'),
656+
new ec2.InstanceType('m5.large'),
657+
],
658+
})).toThrow(/The specified AMI does not match the instance types architecture, either specify one of AL2_x86_64, BOTTLEROCKET_x86_64, WINDOWS_CORE_2019_x86_64, WINDOWS_CORE_2022_x86_64, WINDOWS_FULL_2019_x86_64, WINDOWS_FULL_2022_x86_64 or don't specify any/);
623659
});
624660

625661
/**

0 commit comments

Comments
 (0)