From 3492179052c309070eb4fa500bb3a3e18a2e84bb Mon Sep 17 00:00:00 2001 From: Ilya Dmitrichenko Date: Fri, 7 Dec 2018 22:21:05 +0000 Subject: [PATCH] Tweak the order of create cluster flags --- pkg/ctl/cmdutils/cmdutils.go | 10 +++++----- pkg/ctl/create/cluster.go | 16 +++++++++------- pkg/ctl/delete/cluster.go | 1 + pkg/ctl/utils/describe_stacks.go | 2 +- pkg/ctl/utils/write_kubeconfig.go | 1 + 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pkg/ctl/cmdutils/cmdutils.go b/pkg/ctl/cmdutils/cmdutils.go index de741ca9545..fa95394f2c2 100644 --- a/pkg/ctl/cmdutils/cmdutils.go +++ b/pkg/ctl/cmdutils/cmdutils.go @@ -38,18 +38,18 @@ func AddCommonFlagsForAWS(group *NamedFlagSetGroup, p *api.ProviderConfig) { } fs.DurationVar(&p.WaitTimeout, "timeout", api.DefaultWaitTimeout, "max wait time in any polling operations") }) +} - group.InFlagSet("General", func(fs *pflag.FlagSet) { - fs.StringVarP(&p.Region, "region", "r", "", "AWS region") - }) - +// AddRegionFlag adds common --region flag +func AddRegionFlag(fs *pflag.FlagSet, p *api.ProviderConfig) { + fs.StringVarP(&p.Region, "region", "r", "", "AWS region") } // AddCommonFlagsForKubeconfig adds common flags for controlling how output kubeconfig is written func AddCommonFlagsForKubeconfig(fs *pflag.FlagSet, outputPath *string, setContext, autoPath *bool, exampleName string) { - fs.BoolVar(autoPath, "auto-kubeconfig", false, fmt.Sprintf("save kubeconfig file by cluster name, e.g. %q", kubeconfig.AutoPath(exampleName))) fs.StringVar(outputPath, "kubeconfig", kubeconfig.DefaultPath, "path to write kubeconfig (incompatible with --auto-kubeconfig)") fs.BoolVar(setContext, "set-kubeconfig-context", true, "if true then current-context will be set in kubeconfig; if a context is already set then it will be overwritten") + fs.BoolVar(autoPath, "auto-kubeconfig", false, fmt.Sprintf("save kubeconfig file by cluster name, e.g. %q", kubeconfig.AutoPath(exampleName))) } // ErrUnsupportedRegion is a common error message diff --git a/pkg/ctl/create/cluster.go b/pkg/ctl/create/cluster.go index b76b45f22d8..8804fbd1b95 100644 --- a/pkg/ctl/create/cluster.go +++ b/pkg/ctl/create/cluster.go @@ -57,49 +57,51 @@ func createClusterCmd(g *cmdutils.Grouping) *cobra.Command { group.InFlagSet("General", func(fs *pflag.FlagSet) { fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", fmt.Sprintf("EKS cluster name (generated if unspecified, e.g. %q)", exampleClusterName)) fs.StringToStringVarP(&cfg.Metadata.Tags, "tags", "", map[string]string{}, `A list of KV pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team")`) + cmdutils.AddRegionFlag(fs, p) fs.StringSliceVar(&availabilityZones, "zones", nil, "(auto-select if unspecified)") }) group.InFlagSet("Initial nodegroup", func(fs *pflag.FlagSet) { - fs.StringVarP(&ng.InstanceType, "node-type", "t", defaultNodeType, "node instance type") fs.IntVarP(&ng.DesiredCapacity, "nodes", "N", api.DefaultNodeCount, "total number of nodes (desired capacity of ASG)") // TODO: https://github.com/weaveworks/eksctl/issues/28 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.StringVarP(&ng.InstanceType, "node-type", "t", defaultNodeType, "node instance type") + 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)") - fs.BoolVar(&ng.AllowSSH, "ssh-access", false, "control SSH access for nodes") - fs.StringVar(&ng.SSHPublicKeyPath, "ssh-public-key", defaultSSHPublicKey, "SSH public key to use for nodes (import from local path, or use existing EC2 key pair)") - fs.StringVar(&ng.AMI, "node-ami", ami.ResolverStatic, "Advanced use cases only. If 'static' is supplied (default) then eksctl will use static AMIs; if 'auto' is supplied then eksctl will automatically set the AMI based on region/instance type; if any other value is supplied it will override the AMI to use for the nodes. Use with extreme care.") fs.StringVar(&ng.AMIFamily, "node-ami-family", ami.ImageFamilyAmazonLinux2, "Advanced use cases only. If 'AmazonLinux2' is supplied (default), then eksctl will use the offical AWS EKS AMIs (Amazon Linux 2); if 'Ubuntu1804' is supplied, then eksctl will use the offical Canonical EKS AMIs (Ubuntu 18.04).") + fs.BoolVar(&ng.AllowSSH, "ssh-access", false, "control SSH access for nodes") + fs.StringVar(&ng.SSHPublicKeyPath, "ssh-public-key", defaultSSHPublicKey, "SSH public key to use for nodes (import from local path, or use existing EC2 key pair)") + fs.BoolVarP(&ng.PrivateNetworking, "node-private-networking", "P", false, "whether to make initial nodegroup networking private") }) group.InFlagSet("Cluster add-ons", func(fs *pflag.FlagSet) { - fs.BoolVar(&cfg.Addons.WithIAM.PolicyAmazonEC2ContainerRegistryPowerUser, "full-ecr-access", false, "enable full access to ECR") fs.BoolVar(&cfg.Addons.WithIAM.PolicyAutoScaling, "asg-access", false, "enable iam policy dependency for cluster-autoscaler") + fs.BoolVar(&cfg.Addons.WithIAM.PolicyAmazonEC2ContainerRegistryPowerUser, "full-ecr-access", false, "enable full access to ECR") fs.BoolVar(&cfg.Addons.Storage, "storage-class", true, "if true (default) then a default StorageClass of type gp2 provisioned by EBS will be created") }) group.InFlagSet("VPC networking", func(fs *pflag.FlagSet) { - fs.StringVar(&kopsClusterNameForVPC, "vpc-from-kops-cluster", "", "re-use VPC from a given kops cluster") fs.IPNetVar(cfg.VPC.CIDR, "vpc-cidr", api.DefaultCIDR(), "global CIDR to use for VPC") subnets = map[api.SubnetTopology]*[]string{ api.SubnetTopologyPrivate: fs.StringSlice("vpc-private-subnets", nil, "re-use private subnets of an existing VPC"), api.SubnetTopologyPublic: fs.StringSlice("vpc-public-subnets", nil, "re-use public subnets of an existing VPC"), } + fs.StringVar(&kopsClusterNameForVPC, "vpc-from-kops-cluster", "", "re-use VPC from a given kops cluster") }) cmdutils.AddCommonFlagsForAWS(group, p) group.InFlagSet("Output kubeconfig", func(fs *pflag.FlagSet) { - fs.BoolVar(&writeKubeconfig, "write-kubeconfig", true, "toggle writing of kubeconfig") cmdutils.AddCommonFlagsForKubeconfig(fs, &kubeconfigPath, &setContext, &autoKubeconfigPath, exampleClusterName) + fs.BoolVar(&writeKubeconfig, "write-kubeconfig", true, "toggle writing of kubeconfig") }) group.AddTo(cmd) diff --git a/pkg/ctl/delete/cluster.go b/pkg/ctl/delete/cluster.go index 70ee0a502b8..5ae8955419d 100644 --- a/pkg/ctl/delete/cluster.go +++ b/pkg/ctl/delete/cluster.go @@ -33,6 +33,7 @@ func deleteClusterCmd() *cobra.Command { group.InFlagSet("General", func(fs *pflag.FlagSet) { fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name (required)") + cmdutils.AddRegionFlag(fs, p) fs.BoolVarP(&waitDelete, "wait", "w", false, "Wait for deletion of all resources before exiting") }) diff --git a/pkg/ctl/utils/describe_stacks.go b/pkg/ctl/utils/describe_stacks.go index d9eb4e8dadc..874d9b98f2c 100644 --- a/pkg/ctl/utils/describe_stacks.go +++ b/pkg/ctl/utils/describe_stacks.go @@ -38,7 +38,7 @@ func describeStacksCmd() *cobra.Command { group.InFlagSet("General", func(fs *pflag.FlagSet) { fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name (required)") - + cmdutils.AddRegionFlag(fs, p) fs.BoolVar(&describeStacksAll, "all", false, "include deleted stacks") fs.BoolVar(&describeStacksEvents, "events", false, "include stack events") }) diff --git a/pkg/ctl/utils/write_kubeconfig.go b/pkg/ctl/utils/write_kubeconfig.go index 0f16304503f..c2efb8ee7f4 100644 --- a/pkg/ctl/utils/write_kubeconfig.go +++ b/pkg/ctl/utils/write_kubeconfig.go @@ -40,6 +40,7 @@ func writeKubeconfigCmd() *cobra.Command { group.InFlagSet("General", func(fs *pflag.FlagSet) { fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name (required)") + cmdutils.AddRegionFlag(fs, p) }) group.InFlagSet("Output kubeconfig", func(fs *pflag.FlagSet) {