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
-
Launch Templates for Managed Machine Pools
Table of Contents
Glossary
Summary
Currently, with CAPA we have 2 varieties of Machine Pools implemented called
AWSMachinePool
andAWSManagedMachinePool
. Each variety has a differing level of support for launch templates.The
AWSMachinePool
is used to create an ASG who's EC2 instances are used as worker nodes for the Kubernetes cluster. The specification forAWSMachinePool
exposes settings that are ultimately used to create a EC2 launch template (and version of it thereafter) via theAWSLaunchTemplate
field and struct:(source)
The
AWSManagedMachinePool
is 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 forAWSManagedMachinePool
we 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 useAWSManagedMachinePool
but 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
AWSManagedMachinePool
and 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
AWSMachinePool
andAWSManagedMachinePool
AWSManagedMachinePool
Non-Goals/Future Work
AWSMachinePool
andAWSManagedMachinePool
Proposal
At a high level, the plan is to:
AWSLaunchTemplate
field to AWSManagedMachinePoolSpec that uses the existing AWSLaunchTemplate struct. For example:AWSlaunchTemplate
should be used.LaunchTemplateID
andLaunchTemplateVersion
fields to AWSManagedMachinePoolStatus to store details of the launch template and version used.LaunchTemplateVersion
field to AWSMachinePoolStatus to store the version of the launch template used.AWSMachinePool
controller that reconcilesAWSLaunchTemplate
into a common location so that it can be shared.AWSManagedMachinePool
to use theAWSLaunchTemplate
reconciliation logic.AWSManagedMachinePool
create/update validation webhooks that stops users specifyingAWSLaunchTemplate
if fieldsAMIType,AMIVersion,InstanceType,DiskSize,InstanceProfile
are setAWSManagedMachinePool
create/update validation webhooks if fieldsAMIType,AMIVersion,InstanceType,DiskSize,InstanceProfile
stating that these fields will be deprecated in the future and thatAWSLaunchTemplate
should be used insteadAWSManagedMachinePool
so that they useAWSLaunchTemplate
AWSManagedMachinePool
AWSLaunchTemplate
.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
AWSLaunchTemplate
Non-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
AWSManagedMachinePool
controller 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
AWSLaunchTemplate
CRD & ControllerThe idea is that a
AWSLaunchTemplate
CRD 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
AWSMachinePool
already 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
AWSManagedMachinePool
are optional. Therefore, current users do not have to use the newAWSLaunchTemplate
field. 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
AWSManagedMachinePool
and 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