Skip to content

Commit

Permalink
Improve behaviour of --node{-(min|max)}
Browse files Browse the repository at this point in the history
- update help messages
- bail when --nodes is above --nodes-max
- set --nodes when --nodes-min and --nodes-max are given and it is
  outside the ragne
- print a message when --nodes is default, but --nodes-min as well
  as --nodes-max are set
  • Loading branch information
errordeveloper committed Nov 1, 2018
1 parent 44337ce commit 0542188
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 19 additions & 1 deletion pkg/cfn/builder/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
cfn "github.com/aws/aws-sdk-go/service/cloudformation"
gfn "github.com/awslabs/goformation/cloudformation"

"github.com/kubicorn/kubicorn/pkg/logger"

"github.com/weaveworks/eksctl/pkg/eks/api"

"github.com/weaveworks/eksctl/pkg/nodebootstrap"
Expand Down Expand Up @@ -51,9 +53,25 @@ func (n *NodeGroupResourceSet) AddAllResources() error {
}
n.userData = gfn.NewString(userData)

if n.spec.MinSize == 0 && n.spec.MaxSize == 0 {
switch {
case n.spec.MinSize == 0 && n.spec.MaxSize == 0:
n.spec.MinSize = n.spec.DesiredCapacity
n.spec.MaxSize = n.spec.DesiredCapacity
case n.spec.MinSize > 0 && n.spec.MaxSize > 0:
if n.spec.DesiredCapacity == api.DefaultNodeCount {
msgPrefix := fmt.Sprintf("as --nodes-min=%d and --nodes-max=%d were given", n.spec.MinSize, n.spec.MaxSize)
if n.spec.DesiredCapacity < n.spec.MinSize {
n.spec.DesiredCapacity = n.spec.MaxSize
logger.Info("%s, --nodes=%d was set automatically as default value (--node=%d) was outside the set renge",
msgPrefix, n.spec.DesiredCapacity, api.DefaultNodeCount)
} else {
logger.Info("%s, default value of --nodes=%d was kept as it is within the set range",
msgPrefix, n.spec.DesiredCapacity)
}
}
if n.spec.DesiredCapacity > n.spec.MaxSize {
return fmt.Errorf("cannot use --nodes-max=%d and --nodes=%d at the same time", n.spec.MaxSize, n.spec.DesiredCapacity)
}
}

n.addResourcesForIAM()
Expand Down
6 changes: 3 additions & 3 deletions pkg/ctl/create/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func createClusterCmd() *cobra.Command {
fs.StringToStringVarP(&cfg.Tags, "tags", "", map[string]string{}, `A list of KV pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team")`)

fs.StringVarP(&ng.InstanceType, "node-type", "t", defaultNodeType, "node instance type")
fs.IntVarP(&ng.DesiredCapacity, "nodes", "N", api.DefaultNodeCount, "total number of nodes (for a static ASG)")
fs.IntVarP(&ng.DesiredCapacity, "nodes", "N", api.DefaultNodeCount, "total number of nodes (desired capacity of AGS)")

// TODO: https://github.com/weaveworks/eksctl/issues/28
fs.IntVarP(&ng.MinSize, "nodes-min", "m", 0, "minimum nodes in ASG")
fs.IntVarP(&ng.MaxSize, "nodes-max", "M", 0, "maximum nodes in ASG")
fs.IntVarP(&ng.MinSize, "nodes-min", "m", 0, "minimum nodes in ASG (leave unset for a static nodegroup)")
fs.IntVarP(&ng.MaxSize, "nodes-max", "M", 0, "maximum nodes in ASG (leave unset for a static nodegroup)")

fs.IntVarP(&ng.VolumeSize, "node-volume-size", "", 0, "Node volume size (in GB)")
fs.IntVar(&ng.MaxPodsPerNode, "max-pods-per-node", 0, "maximum number of pods per node (set automatically if unspecified)")
Expand Down

0 comments on commit 0542188

Please sign in to comment.