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

Managed Node Group Launch Template Improvements #1225

Conversation

JustASquid
Copy link
Contributor

Proposed changes

Add the ability to specify gpu/amiId/amiType on a managed node group, and specify disk size when a launch template is created.

This PR is a draft because I haven't been able to test the changes (yet) - any guidance on this is helpful, I don't have easy access to a spare AWS account where I can spin up test clusters.

Related issues (optional)

Resolves #1224

… support setting disk size when a MNG uses a custom launch template
Copy link

github-actions bot commented Jul 3, 2024

PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

*
* Note: `amiType` and `gpu` are mutually exclusive.
*/
amiType?: pulumi.Input<string>;
Copy link
Member

Choose a reason for hiding this comment

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

These looks like something copied over from NodeGroupBaseOptions, I wonder if we could factor this out in TypeScript somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a look, this inherits directly from the AWS config so I figured we shouldn't mess with it too much.

nodejs/eks/nodegroup.ts Outdated Show resolved Hide resolved
@t0yv0
Copy link
Member

t0yv0 commented Jul 3, 2024

Thanks for contributing here! We indeed rely heavily on integration-level tests so an AWS testing account is needed to test the changes.

Copy link

github-actions bot commented Jul 3, 2024

PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

Copy link

github-actions bot commented Jul 3, 2024

PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@JustASquid JustASquid marked this pull request as ready for review July 3, 2024 23:33
@JustASquid
Copy link
Contributor Author

Yep @t0yv0 - Is testing something you're prepared to help with? I do have access to my company's AWS account, but spinning up cluster(s) is a pretty heavy operation so would love to avoid if possible.

@flostadler
Copy link
Contributor

@JustASquid I can help with testing this. Do you want to have a first stab at creating a test?

@JustASquid
Copy link
Contributor Author

Cheers @flostadler - I just went on leave, should be able to take a stab at writing some tests in a couple weeks. Appreciate the help and guidance.

Copy link

PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

Copy link

PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@JustASquid
Copy link
Contributor Author

@flostadler - I added the SDK generation and took a crack at adding some tests - surely they are missing something but hopefully it's a jumping off point.

eks.createManagedNodeGroup(`${projectName}-managed-ng`, {
cluster: cluster,
nodeRole: role,
gpu: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this have any special instance type requirements or can we launch a GPU optimized AMI on a basic t3 instance for example?

@@ -735,6 +735,21 @@ func generateSchema() schema.PackageSpec {
"(https://docs.aws.amazon.com/eks/latest/APIReference/API_Nodegroup.html#AmazonEKS-Type-Nodegroup-amiType) " +
"for valid AMI Types. This provider will only perform drift detection if a configuration value is provided.",
},
"amiId": {
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to run make build and check in the changes to the schema and sdk folder. Otherwise those don't take effect.

Because of the disparity between the nodejs SDK and the rest of the SDKs it would be good to add a test in another language as well (e.g. Golang). Let me know if you need help with converting the test you've created into another language

// Find the recommended AMI for the EKS node group.
// See https://docs.aws.amazon.com/eks/latest/userguide/retrieve-ami-id.html
async function getEksAmiId(k8sVersion: string): Promise<string> {
const client = new SSMClient();
Copy link
Contributor

Choose a reason for hiding this comment

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

You can do that in pulumi natively. See here for an example:

const ami = pulumi.interpolate`/aws/service/eks/optimized-ami/${cluster.core.cluster.version}/amazon-linux-2/recommended/image_id`.apply(name =>
aws.ssm.getParameter({ name }, { async: true })
).apply(result => result.value);

const amiId = cluster.eksCluster.version.apply(version => pulumi.output(getEksAmiId(version)));

// Create a managed node group using a cluster as input.
eks.createManagedNodeGroup(`${projectName}-managed-ng`, {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about combining the ami and gpu tests into one?
One test with two nodegroups should be fine.

We need to balance the number of eks clusters we're creating and here we're interested in the node group.

@@ -1740,7 +1775,7 @@ function createManagedNodeGroupInternal(
}

let launchTemplate: aws.ec2.LaunchTemplate | undefined;
if (args.kubeletExtraArgs || args.bootstrapExtraArgs || args.enableIMDSv2) {
if (args.kubeletExtraArgs || args.bootstrapExtraArgs || args.enableIMDSv2 || args.gpu || args.amiId || args.amiType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to create a custom launch template if amiType is set? That's a valid input for aws.eks.NodeGroup on its own.

Aside from that, the list here gets a bit long now. What do you think about creating a method for deciding whether to create a custom launch template?

@flostadler
Copy link
Contributor

Thanks a lot @JustASquid! I left some comments, let me know if you need some help with any of the proposed changes

@flostadler
Copy link
Contributor

@JustASquid I'm starting to touch the same parts of the code base as part of refactoring needed for #1195. I'd propose that I fold your changes into that to prevent duplication/conflicts.
What do you think about that?

@flostadler
Copy link
Contributor

Closing this in favor of #1195.

@flostadler flostadler closed this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ManagedNodeGroup when creating a LaunchTemplate
3 participants