Skip to content

Commit

Permalink
Merge pull request #403 from mukaibot/master
Browse files Browse the repository at this point in the history
Allow configuring node volume type
  • Loading branch information
errordeveloper authored Jan 9, 2019
2 parents 9ffc6fa + 0f67c56 commit 3b8a4d9
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ To add custom tags for all resources, use `--tags`.
eksctl create cluster --tags environment=staging --region=us-east-1
```

To configure node volume size, use the `--node-volume-size` flag.
To configure node root volume, use the `--node-volume-size` (and optionally `--node-volume-type`), e.g.:

```
eksctl create cluster --node-volume-size=50
eksctl create cluster --node-volume-size=50 --node-volume-type=io1
```

> 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.
Expand Down
37 changes: 32 additions & 5 deletions pkg/apis/eksctl.io/v1alpha3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ const (
// DefaultNodeType is the default instance type to use for nodes
DefaultNodeType = "m5.large"

// DefaultNodeCount defines the default number of nodes to be created
DefaultNodeCount = 2

// DefaultNodeVolumeType defines the default root volume type to use
DefaultNodeVolumeType = NodeVolumeTypeGP2
// NodeVolumeTypeGP2 is General Purpose SSD
NodeVolumeTypeGP2 = "gp2"
// NodeVolumeTypeIO1 is Provisioned IOPS SSD
NodeVolumeTypeIO1 = "io1"
// NodeVolumeTypeSC1 is Throughput Optimized HDD
NodeVolumeTypeSC1 = "sc1"
// NodeVolumeTypeST1 is Cold HDD
NodeVolumeTypeST1 = "st1"

// ClusterNameTag defines the tag of the clsuter name
ClusterNameTag = "eksctl.cluster.k8s.io/v1alpha1/cluster-name"

Expand All @@ -73,6 +87,11 @@ const (
NodeGroupNameLabel = "alpha.eksctl.io/nodegroup-name"
)

var (
// DefaultWaitTimeout defines the default wait timeout
DefaultWaitTimeout = 20 * time.Minute
)

// SupportedRegions are the regions where EKS is available
func SupportedRegions() []string {
return []string{
Expand All @@ -96,11 +115,15 @@ func SupportedVersions() []string {
}
}

// DefaultWaitTimeout defines the default wait timeout
var DefaultWaitTimeout = 20 * time.Minute

// DefaultNodeCount defines the default number of nodes to be created
const DefaultNodeCount = 2
// SupportedNodeVolumeTypes are the volume types that can be used for a node root volume
func SupportedNodeVolumeTypes() []string {
return []string{
NodeVolumeTypeGP2,
NodeVolumeTypeIO1,
NodeVolumeTypeSC1,
NodeVolumeTypeST1,
}
}

// ClusterMeta is what identifies a cluster
type ClusterMeta struct {
Expand Down Expand Up @@ -232,6 +255,8 @@ func (c *ClusterConfig) NewNodeGroup() *NodeGroup {
PrivateNetworking: false,
DesiredCapacity: DefaultNodeCount,
InstanceType: DefaultNodeType,
VolumeSize: 0,
VolumeType: DefaultNodeVolumeType,
}

c.NodeGroups = append(c.NodeGroups, ng)
Expand Down Expand Up @@ -266,6 +291,8 @@ type NodeGroup struct {
// +optional
VolumeSize int `json:"volumeSize"`
// +optional
VolumeType string `json:"volumeType"`
// +optional
MaxPodsPerNode int `json:"maxPodsPerNode,omitempty"`

// +optional
Expand Down
4 changes: 4 additions & 0 deletions pkg/cfn/builder/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ var _ = Describe("CloudFormation template builder API", func() {
ng.Name = "ng-abcd1234"
ng.InstanceType = "t2.medium"
ng.AMIFamily = "AmazonLinux2"
ng.VolumeSize = 2
ng.VolumeType = api.NodeVolumeTypeIO1

*cfg.VPC.CIDR = api.DefaultCIDR()

Expand Down Expand Up @@ -288,6 +290,8 @@ var _ = Describe("CloudFormation template builder API", func() {
Name: "ng-abcd1234",
PrivateNetworking: false,
DesiredCapacity: 2,
VolumeSize: 2,
VolumeType: api.NodeVolumeTypeIO1,
},
},
}
Expand Down
1 change: 1 addition & 0 deletions pkg/cfn/builder/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (n *NodeGroupResourceSet) addResourcesForNodeGroup() error {
DeviceName: gfn.NewString("/dev/xvda"),
Ebs: &gfn.AWSAutoScalingLaunchConfiguration_BlockDevice{
VolumeSize: gfn.NewInteger(n.spec.VolumeSize),
VolumeType: gfn.NewString(n.spec.VolumeType),
},
},
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/ctl/cmdutils/nodegroup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmdutils

import (
"fmt"
"strings"

"github.com/spf13/pflag"

"github.com/weaveworks/eksctl/pkg/ami"
Expand All @@ -21,7 +24,9 @@ func AddCommonCreateNodeGroupFlags(fs *pflag.FlagSet, p *api.ProviderConfig, cfg
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.VolumeSize, "node-volume-size", "", 0, "Node volume size (in GB)")
fs.IntVar(&ng.VolumeSize, "node-volume-size", ng.VolumeSize, "node volume size in GB")
fs.StringVar(&ng.VolumeType, "node-volume-type", ng.VolumeType, fmt.Sprintf("node volume type (valid options: %s)", strings.Join(api.SupportedNodeVolumeTypes(), ", ")))

fs.IntVar(&ng.MaxPodsPerNode, "max-pods-per-node", 0, "maximum number of pods per node (set automatically if unspecified)")

fs.BoolVar(&ng.AllowSSH, "ssh-access", false, "control SSH access for nodes")
Expand Down
6 changes: 6 additions & 0 deletions pkg/ctl/create/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func doCreateCluster(p *api.ProviderConfig, cfg *api.ClusterConfig, nameArg stri
"nodes-max",
"node-type",
"node-volume-size",
"node-volume-type",
"max-pods-per-node",
"node-ami",
"node-ami-family",
Expand Down Expand Up @@ -198,6 +199,11 @@ func doCreateCluster(p *api.ProviderConfig, cfg *api.ClusterConfig, nameArg stri
}
}

if ng.VolumeSize > 0 {
if ng.VolumeType == "" {
ng.VolumeType = api.DefaultNodeVolumeType
}
}
return nil
})
if err != nil {
Expand Down

0 comments on commit 3b8a4d9

Please sign in to comment.