Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-eks): allow the use of graviton3 processors #20543

Merged
merged 8 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-eks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ You may specify one `instanceType` in the launch template or multiple `instanceT
> For more details visit [Launch Template Support](https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html).

Graviton 2 instance types are supported including `c6g`, `m6g`, `r6g` and `t4g`.
Graviton 3 instance types are supported including `c7g`.

### Fargate profiles

Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-eks/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2280,8 +2280,9 @@ function nodeTypeForInstanceType(instanceType: ec2.InstanceType) {

function cpuArchForInstanceType(instanceType: ec2.InstanceType) {
return INSTANCE_TYPES.graviton2.includes(instanceType.toString().substring(0, 3)) ? CpuArch.ARM_64 :
INSTANCE_TYPES.graviton.includes(instanceType.toString().substring(0, 2)) ? CpuArch.ARM_64 :
CpuArch.X86_64;
INSTANCE_TYPES.graviton3.includes(instanceType.toString().substring(0, 3)) ? CpuArch.ARM_64 :
INSTANCE_TYPES.graviton.includes(instanceType.toString().substring(0, 2)) ? CpuArch.ARM_64 :
CpuArch.X86_64;
}

function flatten<A>(xss: A[][]): A[] {
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-eks/lib/instance-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export const INSTANCE_TYPES = {
inferentia: ['inf1'],
graviton: ['a1'],
graviton2: ['c6g', 'm6g', 'r6g', 't4g'],
graviton3: ['c7g'],
};
44 changes: 44 additions & 0 deletions packages/@aws-cdk/aws-eks/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,50 @@ describe('cluster', () => {

});

test('addNodegroupCapacity with C7g instance type comes with nodegroup with correct AmiType', () => {
// GIVEN
const { stack } = testFixtureNoVpc();

// WHEN
new eks.Cluster(stack, 'cluster', {
defaultCapacity: 0,
version: CLUSTER_VERSION,
prune: false,
defaultCapacityInstance: new ec2.InstanceType('c7g.large'),
}).addNodegroupCapacity('ng', {
instanceTypes: [new ec2.InstanceType('c7g.large')],
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::EKS::Nodegroup', {
AmiType: 'AL2_ARM_64',
});

});

test('addAutoScalingGroupCapacity with C7g instance type comes with nodegroup with correct AmiType', () => {
// GIVEN
const { app, stack } = testFixtureNoVpc();

// WHEN
new eks.Cluster(stack, 'cluster', {
defaultCapacity: 0,
version: CLUSTER_VERSION,
prune: false,
}).addAutoScalingGroupCapacity('ng', {
instanceType: new ec2.InstanceType('c7g.large'),
});

// THEN
const assembly = app.synth();
const parameters = assembly.getStackByName(stack.stackName).template.Parameters;
expect(Object.entries(parameters).some(
([k, v]) => k.startsWith('SsmParameterValueawsserviceeksoptimizedami') &&
(v as any).Default.includes('amazon-linux-2-arm64/'),
)).toEqual(true);

});

test('EKS-Optimized AMI with GPU support when addAutoScalingGroupCapacity', () => {
// GIVEN
const { app, stack } = testFixtureNoVpc();
Expand Down
Loading