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.7k stars 3.93k forks source link

EKS: EKS uses AL2_x86_64 AmiType in AWS::EKS::Nodegroup instead of AL2023_x86_64_STANDARD #32211

Open markusl opened 1 day ago

markusl commented 1 day ago

Describe the bug

EKS: EKS uses AL2_x86_64 AmiType in AWS::EKS::Nodegroup instead of AL2023_x86_64_STANDARD

Regression Issue

Last Known Working CDK Version

No response

Expected Behavior

I would expect the latest AMI to be used instead of the old one. Once a cluster is deployed, a message is shown in AWS console: "New AMI release version is available for this node group."

Terraform module also suggests that "Starting on 1.30, AL2023 is the default AMI type for EKS managed node groups" https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/20.29.0

Current Behavior

The following template is generated:

  "EksClusterNodegroupDefaultCapacityE6D932C8": {
   "Type": "AWS::EKS::Nodegroup",
   "Properties": {
    "AmiType": "AL2_x86_64",
...

Reproduction Steps

      const cluster = new eks.Cluster(this, 'EksGpuCluster', {
        vpc: vpc,
        vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }],
        version: eks.KubernetesVersion.V1_31,
        defaultCapacity: 2,
        defaultCapacityInstance: new ec2.InstanceType('m5.xlarge'),
        kubectlLayer: new KubectlV31Layer(this, 'KubectlLayer'),
        outputConfigCommand: true,
        outputClusterName: true,
        authenticationMode: eks.AuthenticationMode.API_AND_CONFIG_MAP,
      });

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.167.1 (build d681b12)

Framework Version

No response

Node.js Version

20

OS

Mac

Language

TypeScript

Language Version

No response

Other information

No response

pahud commented 1 day ago

Yes

https://github.com/aws/aws-cdk/blob/a8bc46d80d5f29f511eebc74c8482c1ac2675349/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts#L488

If props.amiType is not specified, the first element of possibleAmiTypes would be picked, which is AL2_X86_64.

We'll have to shift the order here and this would cause breaking changes and requires a feature flag.

We welcome community PRs.

markusl commented 1 day ago

@pahud Yes, I noticed amiType for addNodegroupCapacity. However, the defaultCapacity and defaultCapacityInstance properties of eks.Cluster do not seem to make it possible to specify AL2023 / Bottlerocket. Is there a workaround for that?