From 32c81b9356775b599a1e886ce507dee5a093e2ce Mon Sep 17 00:00:00 2001 From: Joshua Carp Date: Wed, 26 Sep 2018 17:07:38 -0400 Subject: [PATCH 1/2] Configure node volume size. [Fixes #214] --- README.md | 6 ++++++ cmd/eksctl/create.go | 1 + pkg/cfn/builder/nodegroup.go | 10 ++++++++++ pkg/eks/api/api.go | 11 ++++++----- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 39986f8be5..103454e6d7 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,12 @@ apply to CloudFormation stacks but not EKS clusters. eksctl create cluster --tags environment=staging --region=us-east-1 ``` +To configure node volume size, use the `--node-volume-size` flag. + +``` +eksctl create cluster --node-volume-size 50 +``` + > NOTE: In `us-east-1` you are likely to get `UnsupportedAvailabilityZoneException`. If you do, copy the suggested zones and pass `--zones` flag, e.g. `eksctl create cluster --region=us-east-1 --zones=us-east-1a,us-east-1b,us-east-1d`. This may occur in other regions, but less likely. You shouldn't need to use `--zone` flag otherwise. To delete a cluster, run: diff --git a/cmd/eksctl/create.go b/cmd/eksctl/create.go index 855acf459b..0ba8d9a2fb 100644 --- a/cmd/eksctl/create.go +++ b/cmd/eksctl/create.go @@ -66,6 +66,7 @@ func createClusterCmd() *cobra.Command { fs.StringVarP(&cfg.Region, "region", "r", api.DEFAULT_EKS_REGION, "AWS region") fs.StringVarP(&cfg.Profile, "profile", "p", "", "AWS credentials profile to use (overrides the AWS_PROFILE environment variable)") + fs.IntVarP(&cfg.NodeVolumeSize, "node-volume-size", "", 0, "Node volume size (in GB)") 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(&cfg.NodeType, "node-type", "t", DEFAULT_NODE_TYPE, "node instance type") diff --git a/pkg/cfn/builder/nodegroup.go b/pkg/cfn/builder/nodegroup.go index e2fa5b6965..365283d9f6 100644 --- a/pkg/cfn/builder/nodegroup.go +++ b/pkg/cfn/builder/nodegroup.go @@ -89,6 +89,16 @@ func (n *nodeGroupResourceSet) addResourcesForNodeGroup() { if n.spec.NodeSSH { lc.KeyName = gfn.NewString(n.spec.SSHPublicKeyName) } + if n.spec.NodeVolumeSize > 0 { + lc.BlockDeviceMappings = []gfn.AWSAutoScalingLaunchConfiguration_BlockDeviceMapping{ + { + DeviceName: gfn.NewString("/dev/xvda"), + Ebs: &gfn.AWSAutoScalingLaunchConfiguration_BlockDevice{ + VolumeSize: gfn.NewInteger(n.spec.NodeVolumeSize), + }, + }, + } + } refLC := n.newResource("NodeLaunchConfig", lc) // currently goformation type system doesn't allow specifying `VPCZoneIdentifier: { "Fn::ImportValue": ... }`, // and tags don't have `PropagateAtLaunch` field, so we have a custom method here until this gets resolved diff --git a/pkg/eks/api/api.go b/pkg/eks/api/api.go index 844292998f..f59bf1387f 100644 --- a/pkg/eks/api/api.go +++ b/pkg/eks/api/api.go @@ -34,11 +34,12 @@ type ClusterConfig struct { Tags map[string]string ClusterName string - NodeAMI string - NodeType string - Nodes int - MinNodes int - MaxNodes int + NodeAMI string + NodeType string + Nodes int + NodeVolumeSize int + MinNodes int + MaxNodes int MaxPodsPerNode int From b02525c4a3a92f4c8e4914a8af2fecca9f420ae4 Mon Sep 17 00:00:00 2001 From: Joshua Carp Date: Thu, 27 Sep 2018 10:08:20 -0400 Subject: [PATCH 2/2] Clean up node volume size config. h/t @errordeveloper --- README.md | 2 +- cmd/eksctl/create.go | 2 +- pkg/eks/api/api.go | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 103454e6d7..7c106c9066 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ eksctl create cluster --tags environment=staging --region=us-east-1 To configure node volume size, use the `--node-volume-size` flag. ``` -eksctl create cluster --node-volume-size 50 +eksctl create cluster --node-volume-size=50 ``` > NOTE: In `us-east-1` you are likely to get `UnsupportedAvailabilityZoneException`. If you do, copy the suggested zones and pass `--zones` flag, e.g. `eksctl create cluster --region=us-east-1 --zones=us-east-1a,us-east-1b,us-east-1d`. This may occur in other regions, but less likely. You shouldn't need to use `--zone` flag otherwise. diff --git a/cmd/eksctl/create.go b/cmd/eksctl/create.go index 0ba8d9a2fb..2cda44cd23 100644 --- a/cmd/eksctl/create.go +++ b/cmd/eksctl/create.go @@ -66,7 +66,6 @@ func createClusterCmd() *cobra.Command { fs.StringVarP(&cfg.Region, "region", "r", api.DEFAULT_EKS_REGION, "AWS region") fs.StringVarP(&cfg.Profile, "profile", "p", "", "AWS credentials profile to use (overrides the AWS_PROFILE environment variable)") - fs.IntVarP(&cfg.NodeVolumeSize, "node-volume-size", "", 0, "Node volume size (in GB)") 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(&cfg.NodeType, "node-type", "t", DEFAULT_NODE_TYPE, "node instance type") @@ -76,6 +75,7 @@ func createClusterCmd() *cobra.Command { fs.IntVarP(&cfg.MinNodes, "nodes-min", "m", 0, "minimum nodes in ASG") fs.IntVarP(&cfg.MaxNodes, "nodes-max", "M", 0, "maximum nodes in ASG") + fs.IntVarP(&cfg.NodeVolumeSize, "node-volume-size", "", 0, "Node volume size (in GB)") fs.IntVar(&cfg.MaxPodsPerNode, "max-pods-per-node", 0, "maximum number of pods per node (set automatically if unspecified)") fs.StringSliceVar(&availabilityZones, "zones", nil, "(auto-select if unspecified)") diff --git a/pkg/eks/api/api.go b/pkg/eks/api/api.go index f59bf1387f..41f357db60 100644 --- a/pkg/eks/api/api.go +++ b/pkg/eks/api/api.go @@ -34,12 +34,13 @@ type ClusterConfig struct { Tags map[string]string ClusterName string - NodeAMI string - NodeType string - Nodes int + NodeAMI string + NodeType string + Nodes int + MinNodes int + MaxNodes int + NodeVolumeSize int - MinNodes int - MaxNodes int MaxPodsPerNode int