Skip to content

Add nodes-min and nodes-max flags in ng scale#2022

Merged
cPu1 merged 3 commits intoeksctl-io:masterfrom
sayboras:feature/scaling
May 14, 2020
Merged

Add nodes-min and nodes-max flags in ng scale#2022
cPu1 merged 3 commits intoeksctl-io:masterfrom
sayboras:feature/scaling

Conversation

@sayboras
Copy link
Copy Markdown
Contributor

@sayboras sayboras commented Apr 9, 2020

Description

Fixes #1893
Fixes #809

Approach

I am having below assumptions/scopes while implementing this feature.

  • --nodes flag is mandatory flag
  • following fail fast approach i.e. if there is anything wrong with input, just throw error instead of waiting for error from CF.
  • supporting for configuration file will be done later in separate PR. I would like to hear your inputs if I am going with right direction firstly.

Testing

invalid flag values
$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-max 1 --nodes-min 1
Error: number of nodes must be within range of min nodes and max nodes

$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-max 1              
Error: maximum number of nodes must be greater than or equal to number of nodes

$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-min 3
Error: minimum number of nodes must be less than or equal to number of nodes
no change in current value
$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2                            
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[ℹ]  no change for nodegroup "ng-89ba46f7" in cluster "eksctl-amazing-sculpture-1586756685-cluster": nodes-min 2, desired 2, nodes-max 2

$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-min 2              
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[ℹ]  no change for nodegroup "ng-89ba46f7" in cluster "eksctl-amazing-sculpture-1586756685-cluster": nodes-min 2, desired 2, nodes-max 2

$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-max 2
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[ℹ]  no change for nodegroup "ng-89ba46f7" in cluster "eksctl-amazing-sculpture-1586756685-cluster": nodes-min 2, desired 2, nodes-max 2

$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-min 2 --nodes-max 2
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[ℹ]  no change for nodegroup "ng-89ba46f7" in cluster "eksctl-amazing-sculpture-1586756685-cluster": nodes-min 2, desired 2, nodes-max 2
some changes with desired node, min or max
$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-min 1
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[ℹ]  scaling nodegroup, min size from 2 to 1

$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-max 3
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[ℹ]  scaling nodegroup, max size from 2 to 3

$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 2 --nodes-min 2 --nodes-max 2
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[ℹ]  scaling nodegroup, min size from 1 to 2, max size from 3 to 2
desired node is not within current range from CF
$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 1
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[!]  the desired nodes 1 is less than current nodes-min/minSize 2
Error: failed to scale nodegroup for cluster "amazing-sculpture-1586756685", error the desired nodes 1 is less than current nodes-min/minSize 2

$ ./eksctl scale ng --cluster amazing-sculpture-1586756685 ng-89ba46f7 --nodes 4
[ℹ]  scaling nodegroup stack "eksctl-amazing-sculpture-1586756685-nodegroup-ng-89ba46f7" in cluster eksctl-amazing-sculpture-1586756685-cluster
[!]  the desired nodes 4 is greater than current nodes-max/maxSize 2
Error: failed to scale nodegroup for cluster "amazing-sculpture-1586756685", error the desired nodes 4 is greater than current nodes-max/maxSize 2

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the site/content directory)
  • Manually tested
  • Added labels for change area (e.g. area/nodegroup), target version (e.g. version/0.12.0) and kind (e.g. kind/improvement)
  • Make sure the title of the PR is a good description that can go into the release notes

@sayboras sayboras changed the title Add min and max flags in ng scale Add nodes-min and nodes-max flags in ng scale Apr 13, 2020
@sayboras sayboras marked this pull request as ready for review April 13, 2020 06:42
@sayboras sayboras force-pushed the feature/scaling branch 10 times, most recently from 04647b2 to 36105a3 Compare April 21, 2020 14:07
@sayboras
Copy link
Copy Markdown
Contributor Author

@martina-if @cPu1 for your input and review, happy to address any comment you have 👍

@sayboras sayboras force-pushed the feature/scaling branch 15 times, most recently from 7f4500f to e4d57a3 Compare April 28, 2020 10:15
@sayboras sayboras force-pushed the feature/scaling branch from a85b6b5 to 5a3cdc5 Compare May 4, 2020 10:36
@sayboras sayboras force-pushed the feature/scaling branch from d3c7f35 to 7ed5e64 Compare May 8, 2020 14:49
Copy link
Copy Markdown
Contributor

@cPu1 cPu1 left a comment

Choose a reason for hiding this comment

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

I have left some comments, but otherwise LGTM. ✨

Thanks for the great test coverage for your changes.

Comment thread pkg/cfn/manager/nodegroup.go Outdated
Comment on lines +192 to +197
changed := ng.DesiredCapacity != nil && int64(*ng.DesiredCapacity) != currentCapacity.Int()
changed = changed || (ng.MinSize != nil && (int64(*ng.MinSize) != currentMinSize.Int()))
changed = changed || (ng.MaxSize != nil && (int64(*ng.MaxSize) != currentMaxSize.Int()))
if !changed {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alternatively:

hasChanged := func(desiredVal *int, currentVal gjson.Result) bool {
	return desiredVal != nil && int64(*desiredVal) != currentVal.Int()
}

changed := hasChanged(ng.DesiredCapacity, currentCapacity) || hasChanged(ng.MaxSize, currentMaxSize) || hasChanged(ng.MinSize, currentMinSize)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh good one, I like this inline function style 💯

Comment thread pkg/cfn/manager/nodegroup.go Outdated
Comment thread pkg/cfn/manager/nodegroup_test.go
Comment thread pkg/ctl/scale/nodegroup.go
@sayboras sayboras requested a review from cPu1 May 12, 2020 07:47
Copy link
Copy Markdown
Contributor

@cPu1 cPu1 left a comment

Choose a reason for hiding this comment

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

Nice work. LGTM 🎉

@kalbir
Copy link
Copy Markdown

kalbir commented May 12, 2020

@sayboras does this close #809 as well?

@sayboras
Copy link
Copy Markdown
Contributor Author

does this close #809 as well?

@kalbir yes, it does. Let me update the PR description. Thanks 👍

Comment thread pkg/cfn/manager/nodegroup.go Outdated
@sayboras sayboras requested a review from martina-if May 13, 2020 09:18
sayboras added 3 commits May 14, 2020 22:17
Assumption:
- nodes flag is mandatory
- perform any validation asap and fail fast instead of relying on CF
- cluster config file support will not be out of scope for this PR
+ Use inline function to detect changes
+ Use inline function to update CF stack
@cPu1 cPu1 merged commit 61206b5 into eksctl-io:master May 14, 2020
@sayboras sayboras deleted the feature/scaling branch May 14, 2020 12:38
michi-covalent added a commit to cilium/cilium that referenced this pull request May 26, 2020
Now `--nodes-max` gets set to the same value as `--nodes` by default.

Ref: eksctl-io/eksctl#2022

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
michi-covalent added a commit to cilium/cilium that referenced this pull request Jun 3, 2020
- Create a cluster with `--without-nodegroup` option and create a node
  group after deploying Cilium.
- Change the cluster name to `test-cluster` in the ENI getting started
  so it can use the same "Create a nodegroup" section as the EKS guide.

Ref: eksctl-io/eksctl#2022

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
aanm pushed a commit to cilium/cilium that referenced this pull request Jun 4, 2020
- Create a cluster with `--without-nodegroup` option and create a node
  group after deploying Cilium.
- Change the cluster name to `test-cluster` in the ENI getting started
  so it can use the same "Create a nodegroup" section as the EKS guide.

Ref: eksctl-io/eksctl#2022

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
tklauser pushed a commit to cilium/cilium that referenced this pull request Jun 4, 2020
[ upstream commit 5f1bec8 ]

- Create a cluster with `--without-nodegroup` option and create a node
  group after deploying Cilium.
- Change the cluster name to `test-cluster` in the ENI getting started
  so it can use the same "Create a nodegroup" section as the EKS guide.

Ref: eksctl-io/eksctl#2022

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
borkmann pushed a commit to cilium/cilium that referenced this pull request Jun 5, 2020
[ upstream commit 5f1bec8 ]

- Create a cluster with `--without-nodegroup` option and create a node
  group after deploying Cilium.
- Change the cluster name to `test-cluster` in the ENI getting started
  so it can use the same "Create a nodegroup" section as the EKS guide.

Ref: eksctl-io/eksctl#2022

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow modifying the maxSize value of a NodeGroup w/o changing desired count scale nodegroup with min & max instead of just desired capacity

5 participants