-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group cluster create flags for readability #328
Conversation
`eksctl create cluster -h` now looks like: ``` Create a cluster Usage: eksctl create cluster [flags] Node Flags: --asg-access enable iam policy dependency for cluster-autoscaler --full-ecr-access enable full access to ECR --max-pods-per-node int maximum number of pods per node (set automatically if unspecified) --node-ami string 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. (default "static") --node-ami-family string 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). (default "AmazonLinux2") -P, --node-private-networking whether to make initial nodegroup networking private -t, --node-type string node instance type (default "m5.large") --node-volume-size int Node volume size (in GB) -N, --nodes int total number of nodes (desired capacity of ASG) (default 2) -M, --nodes-max int maximum nodes in ASG (leave unset for a static nodegroup) -m, --nodes-min int minimum nodes in ASG (leave unset for a static nodegroup) --ssh-access control SSH access for nodes --ssh-public-key string SSH public key to use for nodes (import from local path, or use existing EC2 key pair) (default "~/.ssh/id_rsa.pub") --storage-class if true (default) then a default StorageClass of type gp2 provisioned by EBS will be created (default true) Networking Flags: --vpc-cidr ipNet global CIDR to use for VPC (default 192.168.0.0/16) --vpc-from-kops-cluster string re-use VPC from a given kops cluster --vpc-private-subnets strings re-use private subnets of an existing VPC --vpc-public-subnets strings re-use public subnets of an existing VPC --zones strings (auto-select if unspecified) Stack Flags: -r, --region string AWS region --tags stringToString A list of KV pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team") (default []) Other Flags: --auto-kubeconfig save kubeconfig file by cluster name, e.g. "/Users/kuoka-yusuke/.kube/eksctl/clusters/adorable-monster-1543548069" --kubeconfig string path to write kubeconfig (incompatible with --auto-kubeconfig) (default "/Users/kuoka-yusuke/.kube/config") -n, --name string EKS cluster name (generated if unspecified, e.g. "adorable-monster-1543548069") -p, --profile string AWS credentials profile to use (overrides the AWS_PROFILE environment variable) --set-kubeconfig-context if true then current-context will be set in kubeconfig; if a context is already set then it will be overwritten (default true) --timeout duration max wait time in any polling operations (default 20m0s) --write-kubeconfig toggle writing of kubeconfig (default true) Global Flags: -C, --color toggle colorized logs (default true) -v, --verbose int set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging (default 3) ``` Ref eksctl-io#298
It think this is really great, thanks a lot! I am still on vacation until next week, so shall review thoroughly when I am back in the office. |
Thanks! Please enjoy your vacation 🍹 |
This is a successor of eksctl-io#281 but rebased onto the eksctl-io#328 The original credit goes to Richard Case <richard.case@outlook.com> Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
|
||
// The usage template is based on the one bundled into cobra | ||
// https://github.com/spf13/cobra/blob/1e58aa3361fd650121dceeedc399e7189c05674a/command.go#L397 | ||
origFlagUsages := ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use https://github.com/lithammer/dedent here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm, the whole purpose of this seemingly redundant empty lines is to make necessary and enough space between the usage` and the flags section.
That is, if I just wrap it with Decent like origFlagUsages := Decent(
.... )
what you get becomes:
Usage:
eksctl create cluster [flags]
General flags:
-n, --name string EKS cluster name (generated if unspecified, e.g. "adorable-monster-1543548069")
-r, --region string AWS region
--zones strings (auto-select if unspecified)
--tags stringToString A list of KV pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team") (default [])
Initial nodegroup flags:
--max-pods-per-node int maximum number of pods per node (set automatically if unspecified)
Probably this isn't your intention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't notice that. The reason I was suggesting this is to avoid braking indentation, as currently the string has no indentation, and it's in a middle of a function, so it jumps straight at me when I look at it. Perhaps this is just my OCD :)
return cmd | ||
} | ||
|
||
func groupFlagsInUsage(cmd *cobra.Command) { | ||
// Group flags by their categories determined by name prefixes | ||
groupToPatterns := map[string][]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually would be nice to automate this, so we don't have to keep two copies, but I'm happy to merge this as is to start with!
The main thing I would like to discuss here is grouping, the code LGTM. So here is my take on the actual grouping:
Eventually, it'd be nice to also enforce ordering, but for now I think we can live with alphabetical order. |
@errordeveloper Thanks for your review! I slightly prefer Would you mind if I contribute an another PR to address your comment, if this looks ok implementation-wise? Doing so would make me focus on improving things incrementally, without emptying my time due to repetitive rebases across pull requests... 😃 |
Perhaps you want |
Sure, happy to merge, and follow up with a PR of my own, so we can cut a release today.
Yes, probably better. In that version I was just playing with different variations, I wasn't sure if word |
Regarding |
Thanks!
For consistency, having "flags" at the end seems good. I once considered
Sounds good 👍 |
Add node selector for linux node only
Hi! Thanks for maintaining an awesome project☺️
Towards #298, I've tried to group
create cluster
flags as I think appropriate.I've intentionally left the too-long descriptions as-is. I'll work on it in an another PR if you like.
eksctl create cluster -h
now looks like: