EKS Managed Nodegroup with Capacity Reservation in Launch Template through CloudFormation does not use Capacity Reservation.

1

I am creating a Managed Nodegroup for EKS using CloudFormation.

I have an EC2 Launch Template with a CapacityReservationSpecification defined.

The Launch Template is linked to the Managed Nodegroup using CloudFormation. When the Managed Node Group is initialised the Launch Template is copied with an eks-*** prefix in the name. The CapacityReservationSpecification is not copied to the newly generated Launch Template. Cloud Formation script Example:

LaunchTemplate:

Resources:
  LaunchTemplateAux:
    Type: 'AWS::EC2::LaunchTemplate'
    Properties:
      LaunchTemplateData:
        InstanceType: t3.medium
        CapacityReservationSpecification:
          CapacityReservationTarget:
            CapacityReservationResourceGroupArn: {{reservation_group_arn}}
        MetadataOptions:
          HttpPutResponseHopLimit: 2
          HttpTokens: optional
        SecurityGroupIds:
          - xxxxx
      LaunchTemplateName: !Sub '${AWS::StackName}Aux'

NodeGroup:

  ManagedNodeGroupAux:
    Type: 'AWS::EKS::Nodegroup'
    Properties:
      AmiType: AL2_x86_64
      ClusterName: test-cluster
      Labels:
        alpha.eksctl.io/cluster-name: test-cluster
        alpha.eksctl.io/nodegroup-name: test-ng-aux
      LaunchTemplate:
        Id: !Ref LaunchTemplateAux
      NodeRole: node-instance-role::NodeInstanceRole'
      NodegroupName: test-nodegroup
      ScalingConfig:
        DesiredSize: 1
        MaxSize: 2
        MinSize: 1
      Subnets:
        - xxx

The resulting launch templates are as follows. Obtained using the following command aws ec2 describe-launch-template-versions --launch-template-id <template-id> My Launch template Output:

{
    "LaunchTemplateVersions": [
        {
            "LaunchTemplateId": "lt-xx",
            "LaunchTemplateName": "test-cluster-ngAux",
            "VersionNumber": 1,
            "CreateTime": "2022-03-24T12:35:05+00:00",
            "CreatedBy": "xxx:user/xxx",
            "DefaultVersion": true,
            "LaunchTemplateData": {
                "InstanceType": "t3.medium",
                "SecurityGroupIds": [
                    "sg-xxx"
                ],
                "CapacityReservationSpecification": {
                    "CapacityReservationTarget": {
                        "CapacityReservationResourceGroupArn": "arn:aws:resource-groups:xxxxx:group/my-group"
                    }
                },
                "MetadataOptions": {
                    "HttpTokens": "optional",
                    "HttpPutResponseHopLimit": 2
                }
            }
        }
    ]
}

Launch template copied by EKS API:

{
    "LaunchTemplateVersions": [
        {
            "LaunchTemplateId": "lt-xxx",
            "LaunchTemplateName": "eks-xxx",
            "VersionNumber": 1,
            "CreateTime": "2022-03-24T12:35:46+00:00",
            "CreatedBy": "xxx:assumed-role/AWSServiceRoleForAmazonEKSNodegroup/EKS",
            "DefaultVersion": true,
            "LaunchTemplateData": {
                "IamInstanceProfile": {
                    "Name": "xxx"
                },
                "ImageId": "ami-0c37e3f6cdf6a9007",
                "InstanceType": "t3.medium",
                "UserData": "xxx",
                "TagSpecifications": [
                    {
                        "ResourceType": "volume",
                        "Tags": [
                            {
                                "Key": "eks:cluster-name",
                                "Value": "test-cluster"
                            },
                            {
                                "Key": "eks:nodegroup-name",
                                "Value": "test-cluster-ng-aux"
                            }
                        ]
                    },
                    {
                        "ResourceType": "instance",
                "SecurityGroupIds": [
                    "xxx"
                ],
                "MetadataOptions": {
                    "HttpTokens": "optional",
                    "HttpPutResponseHopLimit": 2
                }
            }
        }
    ]
}

1 Answer
1

Hi, I'm on the service team that owns EKS managed nodegroups. Thanks for bringing this to our attention. Looking at copy LaunchTemplate logic, I can see that we don't copy the CapacityReservationResourceGroupArn field in the capacity reservation. Fortunately, that's an easy fix, which I will make right now. It will take 1-2 weeks to deploy to all regions.

answered 2 years ago
  • Is this fix available now?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions