Launch Templates for Managed Machine Pools #3154
richardcase
started this conversation in
Proposals / ADRs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Launch Templates for Managed Machine Pools
Table of Contents
Glossary
Summary
Currently, with CAPA we have 2 varieties of Machine Pools implemented called
AWSMachinePoolandAWSManagedMachinePool. Each variety has a differing level of support for launch templates.The
AWSMachinePoolis used to create an ASG who's EC2 instances are used as worker nodes for the Kubernetes cluster. The specification forAWSMachinePoolexposes settings that are ultimately used to create a EC2 launch template (and version of it thereafter) via theAWSLaunchTemplatefield and struct:(source)
The
AWSManagedMachinePoolis used to create a EKS managed node group which results in an AWS managed ASG being created that utilises AWS managed EC2 instances. In the spec forAWSManagedMachinePoolwe expose details of the pool to create but we don't support using a launch template, and we don't automatically create launch templates (like we do forAWSMachinePool). There have been a number of requests from users of CAPA that have wanted to useAWSManagedMachinePoolbut we don't expose required functionality that only comes with using launch templates.This proposal outlines changes to CAPA that will introduce new capabilities to utilise launch templates for
AWSManagedMachinePooland brings its functionality in line withAWSMachinePool.Motivation
We are increasingly hearing requests from users of CAPA that a particular feature / configuration option isn't exposed by CAPAs implementation of managed machine pools (i.e.
AWSManagedMachinePool) and on investigation the feature is available via a launch template (nitro enclaves or placement as an example). It some instances, users of CAPA have had to use unmanaged machine pools (i.e.AWSMachinePool) instead.The motivation is to improve consistency between the2 varieties of machine pools and expose to the user features of launch templates.
Goals
AWSMachinePoolandAWSManagedMachinePoolAWSManagedMachinePoolNon-Goals/Future Work
AWSMachinePoolandAWSManagedMachinePoolProposal
At a high level, the plan is to:
AWSLaunchTemplatefield to AWSManagedMachinePoolSpec that uses the existing AWSLaunchTemplate struct. For example:AWSlaunchTemplateshould be used.LaunchTemplateIDandLaunchTemplateVersionfields to AWSManagedMachinePoolStatus to store details of the launch template and version used.LaunchTemplateVersionfield to AWSMachinePoolStatus to store the version of the launch template used.AWSMachinePoolcontroller that reconcilesAWSLaunchTemplateinto a common location so that it can be shared.AWSManagedMachinePoolto use theAWSLaunchTemplatereconciliation logic.AWSManagedMachinePoolcreate/update validation webhooks that stops users specifyingAWSLaunchTemplateif fieldsAMIType,AMIVersion,InstanceType,DiskSize,InstanceProfileare setAWSManagedMachinePoolcreate/update validation webhooks if fieldsAMIType,AMIVersion,InstanceType,DiskSize,InstanceProfilestating that these fields will be deprecated in the future and thatAWSLaunchTemplateshould be used insteadAWSManagedMachinePoolso that they useAWSLaunchTemplateAWSManagedMachinePoolAWSLaunchTemplate.User Stories
Story 1
AS a CAPA user
I want to create a managed machine pool using a launch template
So that I can use functionality from the AWS launch template
Story 2
As a CAPA user
I want to have consistency between managed and unmanaged machine pools
So that I can choose which to use based on whether I want managed and not based on missing functionality
Story 3
As a CAPA user
I want to ensure launch templates are versioned
So that I can see a history of the changes in the console
Story 4
As a CAPA user
I want to be able to set the maximum number of versions to keep for launch templates
So that I don't have to worry about cleaning up old versions.
Story 5
As a CAPA user
I want to be able to use the output of a bootstrap provider in my launch template
So that i can bootstrap Kubernetes on the nodes
Requirements
Functional Requirements
FR1: CAPA MUST support using launch templates with non-managed ASG based machine pools (i.e.
AWSMachinePool).FR2: CAPA MUST support using launch templates with EKS managed nodegroup based machine pools (i.e.
AWSManagedMachinePool).FR3: CAPA MUST provide a consistent declarative API to expose Launch Template configuration to the machine pool implementations.
FR4: CAPA MUST manage the lifecycle of a launch template in AWS based on its declaration.
FR5: CAPA MUST version launch templates in AWS.
FR6: CAPA MUST allow keeping a configurable number of previous versions of launch templates.
FR7: CAPA MUST validate the declarations for
AWSLaunchTemplateNon-Functional Requirements
NFR1: CAPA MUST provide logging and tracing to expose the progress of reconciliation of
AWSLaunhcTemplate.NFR2: CAPA MUST raise events at important milestones during reconciliation.
NFR3: CAPA MUST requeue where possible and not wait during reconciliation so as to free up the reconciliation loop
NFR4: CAPA must have e2e tests that cover usage of launch templates with BOTH variants of machine pools.
Implementation Details/Notes/Constraints
The code in reconcileLaunchTemplate must be refactored into a package that can be use by the
AWSManagedMachinePoolcontroller as well. We could think about shifting more of this functionality into the "ec2" service.Cleaning up old versions of launch templates is currently handled by PruneLaunchTemplateVersions which is sufficient for this change. We may want to make the minimum number of versions to keep configurable in the future but this can be covered by a different change.
Security Model
There are no changes required to the security model. Access to the required CRDs is already declared for the controllers and as we are not adding any new kinds this doesn't need to change.
No change is required to the AWS permissions the controller requires for reconciliation.
Risks and Mitigations
The risk is that we are being constrained by the existing API definition used in unmanaged machine pools. This may raise unforeseen issues.
Alternatives
New
AWSLaunchTemplateCRD & ControllerThe idea is that a
AWSLaunchTemplateCRD would be created with an associated controller. The controller would then be responsible for reconciling the definition and managing the lifecycle of launch templates on AWS.Benefits
Downsides
Decision
As
AWSMachinePoolalready managed launch templates, it was felt that we should follow the same approach for consistency and it would be a smaller change.We can revisit the idea of a separate launch template kind in the future. The proposed change in this proposal will not preclude implementing this alternative in the future.
Upgrade Strategy
The changes we are making to
AWSManagedMachinePoolare optional. Therefore, current users do not have to use the newAWSLaunchTemplatefield. On upgrading there will be a new log entry written that informs the user that certain fields will be deprecated in the future.Additional Details
Test Plan
Graduation Criteria
With this proposal, we are planning to deprecate a number of fields on
AWSManagedMachinePooland as this is a beta level API this means:The machine pools feature is also marked as experimental in Cluster API and as such this has to be explicitly enabled via a feature flag. Even though it is experimental, we should adhere to the Kubernetes rules on API deprecation.
So based on the change, we will need to support the deprecated fields until December 2022 or CAPA v1.5...whichever is longer. So probably December 2022
Beta Was this translation helpful? Give feedback.
All reactions