Skip to content

Commit

Permalink
allow creation of cluster using cfg file w/o node groups
Browse files Browse the repository at this point in the history
  • Loading branch information
D3nn committed Feb 21, 2019
1 parent ead2b2a commit 4cf131d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -174,6 +174,13 @@ using `--config-file`:
eksctl create cluster --config-file=<path>
```

To create a cluster using a configuration file and skip creating
nodegroups until later:

```
eksctl create cluster --config-file=<path> --without-nodegroup
```

To delete a cluster, run:

```
Expand Down
1 change: 1 addition & 0 deletions humans.txt
Expand Up @@ -34,6 +34,7 @@ tiffany jernigan @tiffanyfay
Silvio Gutierrez @silviogutierrez
Yandy Ramirez @IPyandy
Jerry Jackson @jrryjcksn
Dann Church @D3nn

/* Thanks */

Expand Down
16 changes: 12 additions & 4 deletions pkg/ctl/create/cluster.go
Expand Up @@ -103,6 +103,15 @@ func createClusterCmd(g *cmdutils.Grouping) *cobra.Command {
return cmd
}

// When passing the --without-nodegroup option, don't create nodegroups
func skipNodeGroupsIfRequested(cfg *api.ClusterConfig) {
if withoutNodeGroup {
cfg.NodeGroups = nil
logger.Warning("cluster will be created without an initial nodegroup")
}
}


// checkEachNodeGroup iterates over each nodegroup and calls check function
// (this is need to avoid common goroutine-for-loop pitfall)
func checkEachNodeGroup(cfg *api.ClusterConfig, check func(i int, ng *api.NodeGroup) error) error {
Expand Down Expand Up @@ -250,6 +259,8 @@ func doCreateCluster(p *api.ProviderConfig, cfg *api.ClusterConfig, nameArg stri
return fmt.Errorf("vpc.subnets and availabilityZones cannot be set at the same time")
}

skipNodeGroupsIfRequested(cfg)

if err := checkEachNodeGroup(cfg, newNodeGroupChecker); err != nil {
return err
}
Expand All @@ -266,10 +277,7 @@ func doCreateCluster(p *api.ProviderConfig, cfg *api.ClusterConfig, nameArg stri
return fmt.Errorf("status fields are read-only")
}

if withoutNodeGroup {
cfg.NodeGroups = nil
logger.Warning("cluster will be created without an initial nodegroup")
}
skipNodeGroupsIfRequested(cfg)

err := checkEachNodeGroup(cfg, func(i int, ng *api.NodeGroup) error {
if ng.AllowSSH && ng.SSHPublicKeyPath == "" {
Expand Down

0 comments on commit 4cf131d

Please sign in to comment.