Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple instance types for managed machine pools #4358

Closed

Conversation

arjunrn
Copy link

@arjunrn arjunrn commented Jun 26, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

EKS node groups support multiple instance types. The order of the instance types and capacity type together determine which instances are created by AWS when the node group is scaled up. Also added validation so that both fields instanceType and instanceTypes cannot be specified together. . Added this as a new field to the AWSManagedMachinePool in in version v1beta2.

Fixes #3585

Special notes for your reviewer:
This new field does not exist in the older v1beta1 type of AWSManagedMachinePool. I'm not sure if it is even needed because the older single instance type field is still present. However code-gen complains that this field is not properly converted. Note that v1beta2 is the stored version so there's no chance for a loss of data.

Checklist:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority labels Jun 26, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @arjunrn!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-aws 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-aws has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 26, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @arjunrn. 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. Regular contributors should join the org to skip this step.

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.

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/test-infra repository.

@arjunrn arjunrn changed the title WIP: Multiple instance types to managed machine pools WIP: Multiple instance types for managed machine pools Jun 26, 2023
@arjunrn arjunrn changed the title WIP: Multiple instance types for managed machine pools Multiple instance types for managed machine pools Jun 26, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 26, 2023
@richardcase
Copy link
Member

/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 Jun 28, 2023
@richardcase richardcase mentioned this pull request Jun 28, 2023
2 tasks
Copy link
Member

@richardcase richardcase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I have added InstanceType to the issue where we are tracking changes for a future v1beta3 API version. so we can drop the field all together in the future.

@@ -120,6 +120,10 @@ type AWSManagedMachinePoolSpec struct {
// +optional
InstanceType *string `json:"instanceType,omitempty"`

// InstanceTypes specifies the AWS instance types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add a note to InstanceType to say the filed is deprecated and that InstanceTypes should be used instead.

When we bump the API version we can then remove the old field

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the note.

@@ -123,6 +123,10 @@ func (r *AWSManagedMachinePool) validateLaunchTemplate() field.ErrorList {
return allErrs
}

if r.Spec.InstanceTypes != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also log in the Create about the deprecation of the InstanceType field

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added log line.

@@ -120,6 +120,10 @@ type AWSManagedMachinePoolSpec struct {
// +optional
InstanceType *string `json:"instanceType,omitempty"`

// InstanceTypes specifies the AWS instance types
// +optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we elaborate in the comment what happens when you specify multiple instances types?
What's the expectation, allocation strategy...?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectation is any of these instance types could be present in the node group. The allocation strategy is completely managed by AWS. Is there anything you think I should mention in the doc string?

Copy link
Member

@enxebre enxebre Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now by reading the API I'm not sure what intent the field is expressing. I'd add something like

The allocation strategy to provision On-Demand capacity is set to prioritized. Managed node groups use the order of instance types passed in the API to determine which instance type to use first when fulfilling On-Demand capacity.

From https://docs.aws.amazon.com/eks/latest/userguide/managed-node-groups.html#managed-node-group-capacity-types

Or at minimum I'd clarify something like

Ordering of the passed values means priority. See https://docs.aws.amazon.com/eks/latest/userguide/managed-node-groups.html#managed-node-group-capacity-types for more info

Just a suggestion feel free to proceed otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that would be a good idea to expand the comment. I quite like the suggestion fro @enxebre 👍

Ordering of the passed values means priority. See https://docs.aws.amazon.com/eks/latest/userguide/managed-node-groups.html#managed-node-group-capacity-types for more info

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the doc string. PTAL.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 29, 2023
@arjunrn arjunrn force-pushed the multi-instance-eks-node-groups branch from c5bdab4 to e7f8f41 Compare June 29, 2023 12:09
@@ -227,6 +227,10 @@ func (s *NodegroupService) createNodegroup() (*eks.Nodegroup, error) {
if managedPool.InstanceType != nil {
input.InstanceTypes = []*string{managedPool.InstanceType}
}
for _, instanceType := range managedPool.InstanceTypes {
Copy link
Member

@enxebre enxebre Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be clarify in the API docs as well that setting both InstanceType and InstanceTypes will append the latter to the former? That UX might come us a surprise. Or maybe event prevent both from being set in validation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's already the case through validation. The code looks this way but the webhooks would prevent both of these from being set.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@enxebre
Copy link
Member

enxebre commented Jul 5, 2023

Just one more comment #4358 (comment).
Otherwise lgtm after squashing commits.

@arjunrn arjunrn force-pushed the multi-instance-eks-node-groups branch from a16dd53 to c151661 Compare July 5, 2023 07:37
@enxebre
Copy link
Member

enxebre commented Jul 6, 2023

nit: commit is missing imperative verb i.e. Add multiple instances...
Also to clarify the commit desc

EKS node groups support multiple instance types

when the capacity type is spot.

This comes in more handy for spot but is also valid for on demand, correct?
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 6, 2023
EKS node groups support [multiple instance types
](https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateNodegroup.html#API_CreateNodegroup_RequestSyntax).
The order of the instance types and capacity type together determine
which instances are created by AWS when the node group is scaled up.
Also added validation so that both fields `instanceType` and
`instanceTypes` cannot be specified together.
@arjunrn arjunrn force-pushed the multi-instance-eks-node-groups branch from c151661 to a5a5187 Compare July 6, 2023 10:18
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 6, 2023
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot
Copy link
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 ask for approval from enxebre. For more information see the Kubernetes Code Review Process.

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

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

@arjunrn
Copy link
Author

arjunrn commented Jul 6, 2023

@enxebre @richardcase Please take another look and let me know if you need anything else.

@arjunrn arjunrn closed this Aug 29, 2023
@richardcase
Copy link
Member

@arjunrn - did you mean to close this?

@idanshaby
Copy link

@richardcase it looks like there was a bit of miscommunication here.
I think that this PR was ready from @arjunrn 's side, and that he was waiting for you to review it.
This is a fundamental functionality that's required for people to use CAPA in production.
Can anyone please try to push it? 🙏

@arjunrn arjunrn deleted the multi-instance-eks-node-groups branch October 31, 2023 09:26
@arjunrn arjunrn restored the multi-instance-eks-node-groups branch October 31, 2023 11:07
@arjunrn
Copy link
Author

arjunrn commented Oct 31, 2023

@idanshaby Please feel free to use the changes in my branch to create a new PR. We've discontinued the use of CAPI/CAPA and I'm not working on this feature any more.

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. kind/feature Categorizes issue or PR as related to a new feature. needs-priority ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support a list of instance types in AWSManagedMachinePool
5 participants