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

Closed
Changes from 1 commit
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
61 changes: 60 additions & 1 deletion nodejs/eks/nodegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,43 @@ export type ManagedNodeGroupOptions = Omit<
* - maxSize: 2
*/
scalingConfig?: pulumi.Input<awsInputs.eks.NodeGroupScalingConfig>;

/**
* The AMI type for the instance.
*
* If you are passing an amiId that is `arm64` type, then we need to ensure
* that this value is set as `amazon-linux-2-arm64`.
*
* 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.


/**
* The AMI ID to use for the worker nodes.
*
* Defaults to the latest recommended EKS Optimized Linux AMI from the
* AWS Systems Manager Parameter Store.
*
* Note: `amiId` and `gpu` are mutually exclusive.
*
* See for more details:
* - https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html.
*/
amiId?: pulumi.Input<string>;
JustASquid marked this conversation as resolved.
Show resolved Hide resolved

/**
* Use the latest recommended EKS Optimized Linux AMI with GPU support for
* the worker nodes from the AWS Systems Manager Parameter Store.
*
* Defaults to false.
*
* Note: `gpu` and `amiId` are mutually exclusive.
*
* See for more details:
* - https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html.
* - https://docs.aws.amazon.com/eks/latest/userguide/retrieve-ami-id.html
*/
gpu?: pulumi.Input<boolean>;
};

/**
Expand Down Expand Up @@ -1668,6 +1705,14 @@ function createManagedNodeGroupInternal(
);
}

if (args.amiId && args.gpu) {
throw new pulumi.ResourceError("amiId and gpu are mutually exclusive.", parent);
}

if (args.amiType && args.gpu) {
throw new pulumi.ResourceError("amiType and gpu are mutually exclusive.", parent);
}

let roleArn: pulumi.Input<string>;
if (args.nodeRoleArn) {
roleArn = args.nodeRoleArn;
Expand Down Expand Up @@ -1740,8 +1785,11 @@ 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?

launchTemplate = createMNGCustomLaunchTemplate(name, args, core, parent, provider);

// Disk size is specified in the launch template.
delete nodeGroupArgs.diskSize;
JustASquid marked this conversation as resolved.
Show resolved Hide resolved
}

// Make the aws-auth configmap a dependency of the node group.
Expand Down Expand Up @@ -1836,9 +1884,20 @@ Content-Type: text/x-shellscript; charset="us-ascii"
? { httpTokens: "required", httpPutResponseHopLimit: 2, httpEndpoint: "enabled" }
: undefined;

const blockDeviceMappings = [
{
deviceName: "/dev/xvda",
ebs: {
volumeSize: args.diskSize,
volumeType: "gp2"
},
},
];

return new aws.ec2.LaunchTemplate(
`${name}-launchTemplate`,
{
blockDeviceMappings,
userData,
metadataOptions,
// We need to always supply an imageId, otherwise AWS will attempt to merge the user data which will result in
Expand Down
Loading