-
Notifications
You must be signed in to change notification settings - Fork 640
Multiple instance types for managed machine pools #4358
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,10 @@ func (r *AWSManagedMachinePool) validateLaunchTemplate() field.ErrorList { | |
| return allErrs | ||
| } | ||
|
|
||
| if r.Spec.InstanceTypes != nil { | ||
|
||
| allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "InstanceTypes"), r.Spec.InstanceTypes, "InstanceTypes cannot be specified when LaunchTemplate is specified")) | ||
| } | ||
|
|
||
| if r.Spec.InstanceType != nil { | ||
| allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "InstanceType"), r.Spec.InstanceType, "InstanceType cannot be specified when LaunchTemplate is specified")) | ||
| } | ||
|
|
@@ -158,13 +162,20 @@ func (r *AWSManagedMachinePool) ValidateCreate() error { | |
| if errs := r.validateLaunchTemplate(); len(errs) > 0 { | ||
| allErrs = append(allErrs, errs...) | ||
| } | ||
| if errs := r.validateInstanceConfig(); len(errs) > 0 { | ||
| allErrs = append(allErrs, errs...) | ||
| } | ||
|
|
||
| allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...) | ||
|
|
||
| if len(allErrs) == 0 { | ||
| return nil | ||
| } | ||
|
|
||
| if r.Spec.InstanceType != nil { | ||
| mmpLog.Info("AWSManagedMachine pool spec.instanceType is deprecated", "managed-machine-pool", klog.KObj(r)) | ||
| } | ||
|
|
||
| return apierrors.NewInvalid( | ||
| r.GroupVersionKind().GroupKind(), | ||
| r.Name, | ||
|
|
@@ -195,6 +206,9 @@ func (r *AWSManagedMachinePool) ValidateUpdate(old runtime.Object) error { | |
| if errs := r.validateLaunchTemplate(); len(errs) > 0 { | ||
| allErrs = append(allErrs, errs...) | ||
| } | ||
| if errs := r.validateInstanceConfig(); len(errs) > 0 { | ||
| allErrs = append(allErrs, errs...) | ||
| } | ||
|
|
||
| if len(allErrs) == 0 { | ||
| return nil | ||
|
|
@@ -214,6 +228,14 @@ func (r *AWSManagedMachinePool) ValidateDelete() error { | |
| return nil | ||
| } | ||
|
|
||
| func (r *AWSManagedMachinePool) validateInstanceConfig() field.ErrorList { | ||
| var allErrs field.ErrorList | ||
| if r.Spec.InstanceType != nil && r.Spec.InstanceTypes != nil { | ||
| allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "InstanceTypes"), "InstanceTypes cannot be specified when InstanceType is set")) | ||
| } | ||
| return allErrs | ||
| } | ||
|
|
||
| func (r *AWSManagedMachinePool) validateImmutable(old *AWSManagedMachinePool) field.ErrorList { | ||
| var allErrs field.ErrorList | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
||
| input.InstanceTypes = append(input.InstanceTypes, aws.String(instanceType)) | ||
| } | ||
|
|
||
| if len(managedPool.Taints) > 0 { | ||
| s.Info("adding taints to nodegroup", "nodegroup", nodegroupName) | ||
| taints, err := converters.TaintsToSDK(managedPool.Taints) | ||
|
|
||
There was a problem hiding this comment.
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...?
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
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
Just a suggestion feel free to proceed otherwise.
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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.