Skip to content

✨ Add ExistingLaunchTemplate (BYO) support for EKS managed node groups#5906

Open
AmitSahastra wants to merge 3 commits intokubernetes-sigs:mainfrom
AmitSahastra:byo-launch-template-eks-nodegroup
Open

✨ Add ExistingLaunchTemplate (BYO) support for EKS managed node groups#5906
AmitSahastra wants to merge 3 commits intokubernetes-sigs:mainfrom
AmitSahastra:byo-launch-template-eks-nodegroup

Conversation

@AmitSahastra
Copy link
Copy Markdown
Contributor

@AmitSahastra AmitSahastra commented Mar 16, 2026

What this PR does

Adds a new existingLaunchTemplate field to AWSManagedMachinePoolSpec that allows users to reference a pre-existing (BYO) AWS launch template by ID or name for EKS managed node groups, instead of having CAPA create and manage one.

This enables use cases where organizations manage launch templates externally (e.g. via Terraform, CloudFormation, or the AWS console) and want CAPA to use them as-is.

Fixes #5896

Key changes

API (v1beta1 + v1beta2):

  • New ExistingLaunchTemplateRef type with id, name, and version fields
  • New existingLaunchTemplate field on AWSManagedMachinePoolSpec, mutually exclusive with awsLaunchTemplate

Controller:

  • Resolves BYO launch template by ID or name during reconciliation
  • Sets launch template ID and version in status
  • Skips launch template deletion for BYO templates

Webhook validation:

  • Mutual exclusivity between existingLaunchTemplate and awsLaunchTemplate
  • Requires exactly one of id or name
  • Requires version
  • id and name are immutable; version is intentionally mutable (to allow rolling out new LT versions)
  • diskSize and instanceType are rejected when any launch template is specified

Nodegroup service:

  • BYO launch template is passed to CreateNodegroup and UpdateNodegroupVersion
  • Symbolic version handling ($Latest, $Default) to avoid endless reconcile loops
  • Guard against nil Version/ReleaseVersion on failed nodegroups

Tests:

  • Webhook: create and update validation tests for all BYO launch template scenarios
  • Nodegroup: unit tests for isSymbolicLaunchTemplateVersion helper

How to test

  1. Create an EC2 launch template in AWS
  2. Reference it in an AWSManagedMachinePool spec:
spec:
  existingLaunchTemplate:
    id: lt-xxxxxxxxxxxx
    version: "1"
  1. The node group should be created using the referenced launch template
  2. CAPA should NOT delete the launch template on pool deletion

Release note:

  Add BYO launch template support for EKS managed node groups

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 16, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign damdo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 16, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @AmitSahastra. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 16, 2026
@AmitSahastra AmitSahastra force-pushed the byo-launch-template-eks-nodegroup branch 2 times, most recently from 962cb7e to ec3d921 Compare March 16, 2026 07:47
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Mar 16, 2026
@AmitSahastra AmitSahastra changed the title Add ExistingLaunchTemplate (BYO) support for EKS managed node groups feat: Add ExistingLaunchTemplate (BYO) support for EKS managed node groups Mar 16, 2026
@AmitSahastra AmitSahastra changed the title feat: Add ExistingLaunchTemplate (BYO) support for EKS managed node groups ✨ Add ExistingLaunchTemplate (BYO) support for EKS managed node groups Mar 16, 2026
@AmitSahastra AmitSahastra force-pushed the byo-launch-template-eks-nodegroup branch from ec3d921 to 10b2118 Compare March 17, 2026 09:02
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 17, 2026
@AmitSahastra AmitSahastra force-pushed the byo-launch-template-eks-nodegroup branch from 10b2118 to 02021ae Compare March 17, 2026 10:28
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 10, 2026
@AmitSahastra
Copy link
Copy Markdown
Contributor Author

Hi @fiunchinho @serngawy the bot suggested I consider joining the kubernetes-sigs org given my contributions. Would either of you be willing to sponsor me for membership? I'm happy to open the formal request at https://github.com/kubernetes/org/issues/new?template=membership.md once I have two sponsors confirmed. Thanks!

Comment thread exp/api/v1beta1/types.go Outdated
Comment thread exp/api/v1beta2/types.go
@AmitSahastra AmitSahastra force-pushed the byo-launch-template-eks-nodegroup branch from d6487c5 to b292a1b Compare April 15, 2026 04:41
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 15, 2026
Allow users to reference a pre-existing (BYO) AWS EC2 launch template by
ID in AWSManagedMachinePoolSpec.AWSLaunchTemplate, instead of having CAPA
create and manage one.

When AWSLaunchTemplate.ID is set:
- CAPA uses the referenced template directly and will not create, update,
  or delete it
- versionNumber is required; CAPA-managed fields (ami, instanceType,
  sshKeyName, rootVolume, etc.) are forbidden
- ID and Name are immutable after creation; versionNumber is mutable to
  support rolling out new template versions without replacing the nodegroup

Key changes:
- New ID field on exp/api/v1beta2.AWSLaunchTemplate with CEL immutability
  rule; v1beta1 is NOT modified (field is v1beta2-only per deprecation
  policy); ID survives v1beta2→v1beta1→v1beta2 round-trips via the CAPI
  MarshalData/UnmarshalData annotation mechanism, restored in ConvertTo
  for both AWSManagedMachinePool and AWSMachinePool
- Generated files (CRDs, deepcopy, conversion) produced by make generate;
  v1beta1 CRD schema has no id field or XValidation rules
- IsBYOLaunchTemplate() scope helper gates controller and nodegroup service
  to skip LT create/delete lifecycle for BYO templates
- Webhook validates BYO-specific invariants and immutability
- launchTemplateNeedsUpdate() helper covers ID changes and concrete version
  changes while skipping symbolic aliases ($Latest, $Default) to prevent
  endless reconcile loops
- Guard against nil Version/ReleaseVersion on CREATE_FAILED/DELETE_FAILED
  nodegroups
- LaunchTemplateNeedsUpdate returns a reason enum for improved log output
- e2e test (BYOMachinePoolSpec): creates a real EC2 launch template,
  creates the nodegroup, and verifies the nodegroup uses the BYO template ID

Signed-off-by: Amit Sahastrabuddhe <amit.sahastra@gmail.com>
@AmitSahastra AmitSahastra force-pushed the byo-launch-template-eks-nodegroup branch from 459ba3d to 07c03fa Compare April 15, 2026 07:21
Comment thread exp/webhooks/awsmanagedmachinepool_webhook.go
@serngawy
Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 17, 2026
Comment thread exp/webhooks/awsmanagedmachinepool_webhook.go Outdated
@AmitSahastra
Copy link
Copy Markdown
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support BYO (Bring Your Own) launch template for EKS managed node groups

4 participants