Skip to content

Commit 3b96a9b

Browse files
committed
Add more command line params - timeout and volume-iops
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
1 parent 7697f5f commit 3b96a9b

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

pkg/resource/cluster/cluster.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import (
99
)
1010

1111
func NewResource() *resource.Resource {
12+
resManager := &eksctl.ResourceManager{
13+
Resource: "cluster",
14+
ConfigTemplate: &template.TextTemplate{
15+
Template: eksctl.EksctlHeader + EksctlTemplate + nodegroup.EksctlTemplate,
16+
},
17+
DeleteFlags: []string{"--disable-nodegroup-eviction"},
18+
}
1219
res := &resource.Resource{
1320
Command: cmd.Command{
1421
Name: "cluster",
@@ -17,19 +24,11 @@ func NewResource() *resource.Resource {
1724
CreateArgs: []string{"NAME"},
1825
Args: []string{"NAME"},
1926
},
20-
21-
Getter: &Getter{},
22-
23-
Manager: &eksctl.ResourceManager{
24-
Resource: "cluster",
25-
ConfigTemplate: &template.TextTemplate{
26-
Template: eksctl.EksctlHeader + EksctlTemplate + nodegroup.EksctlTemplate,
27-
},
28-
DeleteFlags: []string{"--disable-nodegroup-eviction"},
29-
},
27+
Getter: &Getter{},
28+
Manager: resManager,
3029
}
3130

32-
return addOptions(res)
31+
return addOptions(res, resManager)
3332
}
3433

3534
const EksctlTemplate = `

pkg/resource/cluster/options.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net"
66
"os"
77
"strings"
8+
"time"
89

910
awssdk "github.com/aws/aws-sdk-go-v2/aws"
1011
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
@@ -15,6 +16,7 @@ import (
1516
"github.com/awslabs/eksdemo/pkg/application/storage/ebs_csi"
1617
"github.com/awslabs/eksdemo/pkg/aws"
1718
"github.com/awslabs/eksdemo/pkg/cmd"
19+
"github.com/awslabs/eksdemo/pkg/eksctl"
1820
"github.com/awslabs/eksdemo/pkg/kubernetes"
1921
"github.com/awslabs/eksdemo/pkg/resource"
2022
"github.com/awslabs/eksdemo/pkg/resource/cloudformation_stack"
@@ -46,9 +48,10 @@ type ClusterOptions struct {
4648
appsForIrsa []*application.Application
4749
IrsaTemplate *template.TextTemplate
4850
IrsaRoles []*resource.Resource
51+
Timeout time.Duration
4952
}
5053

51-
func addOptions(res *resource.Resource) *resource.Resource {
54+
func addOptions(res *resource.Resource, resMgr *eksctl.ResourceManager) *resource.Resource {
5255
ngOptions, ngFlags, _ := nodegroup.NewOptions()
5356

5457
options := &ClusterOptions{
@@ -175,7 +178,7 @@ func addOptions(res *resource.Resource) *resource.Resource {
175178
CommandFlag: cmd.CommandFlag{
176179
Name: "vpc-cidr",
177180
Description: "CIDR to use for EKS Cluster VPC",
178-
Validate: func(cmd *cobra.Command, args []string) error {
181+
Validate: func(_ *cobra.Command, _ []string) error {
179182
_, _, err := net.ParseCIDR(options.VpcCidr)
180183
if err != nil {
181184
return fmt.Errorf("failed parsing --vpc-cidr, %w", err)
@@ -199,6 +202,20 @@ func addOptions(res *resource.Resource) *resource.Resource {
199202
},
200203
Option: &options.Addons,
201204
},
205+
&cmd.DurationFlag{
206+
CommandFlag: cmd.CommandFlag{
207+
Name: "timeout",
208+
Description: "maximum waiting time for any long-running operation",
209+
Validate: func(_ *cobra.Command, _ []string) error {
210+
if options.Timeout.Seconds() > 0 {
211+
resMgr.CreateFlags = append(resMgr.CreateFlags,
212+
fmt.Sprintf("--timeout=%s", options.Timeout.String()))
213+
}
214+
return nil
215+
},
216+
},
217+
Option: &options.Timeout,
218+
},
202219
}
203220

204221
res.CreateFlags = append(ngFlags, flags...)

pkg/resource/nodegroup/options.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type NodegroupOptions struct {
4747
SpotvCPUs int
4848
SpotMemory int
4949
Taints []Taint
50+
VolumeIOPS int
5051
VolumeSize int
5152
VolumeType string
5253

@@ -122,6 +123,21 @@ func NewOptions() (options *NodegroupOptions, createFlags, updateFlags cmd.Flags
122123
},
123124
Option: &options.VolumeType,
124125
},
126+
&cmd.IntFlag{
127+
CommandFlag: cmd.CommandFlag{
128+
Name: "volume-iops",
129+
Description: "IOPS for io1/io2 volumes",
130+
Validate: func(_ *cobra.Command, _ []string) error {
131+
if options.VolumeType == "io1" || options.VolumeType == "io2" {
132+
if options.VolumeIOPS < 100 || options.VolumeIOPS > 64000 {
133+
return fmt.Errorf("IOPS must be between 100 and 64000")
134+
}
135+
}
136+
return nil
137+
},
138+
},
139+
Option: &options.VolumeIOPS,
140+
},
125141
&cmd.IntFlag{
126142
CommandFlag: cmd.CommandFlag{
127143
Name: "nodes",

0 commit comments

Comments
 (0)