Skip to content

Commit

Permalink
feat(aws-eks): allow the use of graviton3 processors (#20543)
Browse files Browse the repository at this point in the history
feat: allow the use of graviton3, 7th generation processors

fixes: #20482

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
gergnz committed Jun 20, 2022
1 parent 26ff3c7 commit 98b52de
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 58 deletions.
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

0 comments on commit 98b52de

Please sign in to comment.