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(eks): support CUSTOM amiType #30660

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Artemigos
Copy link

Issue # (if applicable)

Closes #30641.

Reason for this change

Node groups with custom AMI are supported by CloudFormation, but not by CDK. This adds that support.

Description of changes

  • added CUSTOM to the NodegroupAmiType enum
  • always add CUSTOM to possibleAmiTypes when validating instanceTypes CPU architecture against amiType
  • verify that launchTemplateSpec is defined when using CUSTOM

Description of how you validated changes

Added unit tests checking valid deployment as well as failure when CUSTOM is used, but launchTemplateSpec isn't defined.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Jun 25, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team June 25, 2024 12:33
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review June 28, 2024 07:54

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 28, 2024
This was referenced Jul 1, 2024
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍 Left some comments for minor adjustments

@@ -426,7 +430,7 @@ export class Nodegroup extends Resource implements INodegroup {
* 1. instance types of different CPU architectures are not mixed(e.g. X86 with ARM).
* 2. user-specified amiType should be included in `possibleAmiTypes`.
*/
possibleAmiTypes = getPossibleAmiTypes(instanceTypes);
possibleAmiTypes = getPossibleAmiTypes(instanceTypes).concat(NodegroupAmiType.CUSTOM);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please concatenate inside the method for reusability?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved :)

@@ -442,6 +446,11 @@ export class Nodegroup extends Resource implements INodegroup {
}
}

// custom AMI type can be used only when there's a launch template that picks an AMI
if (props.amiType === NodegroupAmiType.CUSTOM && !props.launchTemplateSpec) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update the comments here and here accordingly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a little bit of clarification in both places.

@@ -227,6 +227,27 @@ cluster.addNodegroupCapacity('custom-node-group', {
});
```

To use a custom AMI for the node group, you can set `amiType` to `eks.NodegroupAmiType.CUSTOM` and provide a launch template.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To use a custom AMI for the node group, you can set `amiType` to `eks.NodegroupAmiType.CUSTOM` and provide a launch template.
To use a custom AMI for the node group, you can set `amiType` to `CUSTOM`.
A launch template must be provided.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change applied

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 29, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 432ead4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Aug 12, 2024
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making the changes. Left some comments and questions.

@@ -651,5 +662,5 @@ function getPossibleAmiTypes(instanceTypes: InstanceType[]): NodegroupAmiType[]
throw new Error('instanceTypes of different architectures is not allowed');
}

return archAmiMap.get(Array.from(architectures)[0])!;
return archAmiMap.get(Array.from(architectures)[0])!.concat(NodegroupAmiType.CUSTOM);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of concat here, should we just add it directly to the x8664AmiTypes, arm64AmiTypes, etc. Otherwise this line of code would be easily missed and maintainers and other contributors may not realize those amiTypes are not accurate and complete.

Comment on lines +200 to +201
* The AMI type for your node group. If you explicitly specify the launchTemplate with custom AMI, either set this property to `CUSTOM` or leave
* it undefined, otherwise the node group deployment will fail. In other cases, you will need to specify correct amiType for the nodegroup.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so for my own understanding, CUSTOM ami type is supported now if we leave it unset?

Comment on lines +230 to +231
To use a custom AMI for the node group, you can set `amiType` to `CUSTOM`.
A launch template must be provided.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the comment above, if custom AMI is supported now leaving the amiType property unset, we should call that out in the README too.

Copy link
Contributor

@shikha372 shikha372 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marking it as requested changes based on previous feedback provided by @GavinZZ

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-eks: Support CUSTOM AMI type on Nodegroups
5 participants