Skip to content

Commit

Permalink
Merge branch 'main' into epolon/ignore-types-jest
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jun 21, 2022
2 parents 889e17b + 98b52de commit 755eed8
Show file tree
Hide file tree
Showing 23 changed files with 2,178 additions and 440 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
Loading

0 comments on commit 755eed8

Please sign in to comment.