aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.46k stars 3.82k forks source link

EKS: `LaunchTemplateSpotOptions` are not supported while create=ing EKS Managed Node Groups with a Launch Template. #24730

Open elamaran11 opened 1 year ago

elamaran11 commented 1 year ago

Describe the bug

Trying to create an EKS Managed Node Group with a Launch Template using CDK EKS/EC2 module with following spot options.

    const launchTemplateSpotOptions: ec2.LaunchTemplateSpotOptions = {
        blockDuration: cdk.Duration.hours(1),
        interruptionBehavior: ec2.SpotInstanceInterruption.STOP,
        maxPrice: 10,
        requestType: ec2.SpotRequestType.ONE_TIME,
        validUntil: cdk.Expiration.after(cdk.Duration.days(90))
    };

EKS Managed Nodegroup creation fails with following error :

7:02:50 PM | CREATE_FAILED        | AWS::EKS::Nodegroup                   | blueprintconstruct...templatengECF74DC1
Resource handler returned message: "Instance market options are not supported with the launch template. (Service: Eks, St
atus Code: 400, Request ID: 2bc085ab-99cd-4486-9f9b-b42153b76d3a)" (RequestToken: a323e32a-614f-6a62-f4ee-01a952674903, H
andlerErrorCode: InvalidRequest)

This clearly shows that NodeGroup creation of EKS wont support Launch template with spot options.

Expected Behavior

EKS Managed Node group creation to support Launch template with Spot options with CDK.

Current Behavior

EKS Managed Nodegroup creation fails with following error :

7:02:50 PM | CREATE_FAILED        | AWS::EKS::Nodegroup                   | blueprintconstruct...templatengECF74DC1
Resource handler returned message: "Instance market options are not supported with the launch template. (Service: Eks, St
atus Code: 400, Request ID: 2bc085ab-99cd-4486-9f9b-b42153b76d3a)" (RequestToken: a323e32a-614f-6a62-f4ee-01a952674903, H
andlerErrorCode: InvalidRequest)

Reproduction Steps

Try to create a Launch template with following options and use the same while creating EKS Node Group.

    const launchTemplateSpotOptions: ec2.LaunchTemplateSpotOptions = {
        blockDuration: cdk.Duration.hours(1),
        interruptionBehavior: ec2.SpotInstanceInterruption.STOP,
        maxPrice: 10,
        requestType: ec2.SpotRequestType.ONE_TIME,
        validUntil: cdk.Expiration.after(cdk.Duration.days(90))
    };

Possible Solution

Adding support for EKS Managed Node group creation to support Launch template with Spot options with CDK.

Additional Information/Context

No response

CDK CLI Version

2.67

Framework Version

No response

Node.js Version

v19.6.1

OS

Mac/Ubuntu

Language

Typescript

Language Version

No response

Other information

No response

pahud commented 1 year ago

I am afraid this is a limitation from EKS or CFN. Thanks for the report. I will circle back if I have any updates.

pahud commented 1 year ago

Hi

According to this document, RequestSpotInstances is not supported in LuanchTemplate so I am afraid it's the limit from EKS rather than CDK.

elamaran11 commented 1 year ago

Hi @pahud Thankyou for your response. I understand your pointers. The request is for SpotOptions, Spot Instances does work for us. I do see that EKS Managed Node Groups is not supporting Spot Options though it supports to create MNG with LaunchTemplate having spot reference. We raised this request to check if there is a way to get over this limitation.

pahud commented 1 year ago

@elamaran11 Thank you for clarification. This seems to be a limitation on CFN side that CDK would probably not be able to work around. I would suggest open an issue on aws/containers-roadmap and link back to this issue. I believe the container team would love to hear customer feedback like this. By the time CFN remove this blocker, CDK would be able to support it I believe.

elamaran11 commented 1 year ago

https://github.com/aws/containers-roadmap/issues/1575 @pahud There is already a ticket on Containers Roadmap for this. Should we keep this ticket active until this is resolved.