kubeadm
kubeadm copied to clipboard
Improve tips of incorrect input of kubedm some subcommand
Is this a BUG REPORT or FEATURE REQUEST?
Now the error input tips of kubedm command is the same, e.g.:
[root@k8s-master:~]$ kubeadm config
missing subcommand; "config" is not meant to be run on its own
To see the stack trace of this error execute with --v=5 or higher
[root@k8s-master:~]$
[root@k8s-master:~]$ kubeadm config as
invalid subcommand: "as"
To see the stack trace of this error execute with --v=5 or higher
[root@k8s-master:~]$
[root@k8s-master:~]$
[root@k8s-master:~]$ kubeadm config images
missing subcommand; "images" is not meant to be run on its own
To see the stack trace of this error execute with --v=5 or higher
[root@k8s-master:~]$ kubeadm token
missing subcommand; "token" is not meant to be run on its own
To see the stack trace of this error execute with --v=5 or higher
It doesn't look friendly for the code:
https://github.com/kubernetes/kubernetes/blob/f19a26a22ebe26de32319d57231da9812862aaf6/cmd/kubeadm/app/cmd/util/cmdutil.go#L42-L50
and CheckErr
For some subcommands, do we improve error tips for users, e.g.:
# kubeadm config
There is a ConfigMap in the kube-system namespace called "kubeadm-config" that kubeadm uses to store internal configuration about the
cluster. kubeadm CLI v1.8.0+ automatically creates this ConfigMap with the config used with 'kubeadm init', but if you
initialized your cluster using kubeadm v1.7.x or lower, you must use the 'config upload' command to create this
ConfigMap. This is required so that 'kubeadm upgrade' can configure your upgraded cluster correctly.
Usage:
kubeadm config [flags]
kubeadm config [command]
Available Commands:
images Interact with container images used by kubeadm
migrate Read an older version of the kubeadm configuration API types from a file, and output the similar config object for the newer version
print Print configuration
Flags:
-h, --help help for config
--kubeconfig string The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file. (default "/etc/kubernetes/admin.conf")
Global Flags:
--add-dir-header If true, adds the file directory to the header of the log messages
--log-file string If non-empty, use this log file (no effect when -logtostderr=true)
--log-file-max-size uint Defines the maximum size a log file can grow to (no effect when -logtostderr=true). Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--one-output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
--rootfs string [EXPERIMENTAL] The path to the 'real' host root filesystem.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
-v, --v Level number for the log level verbosity
Use "kubeadm config [command] --help" for more information about a command.
# kubeadm config images
Interact with container images used by kubeadm
Usage:
kubeadm config images [flags]
kubeadm config images [command]
Available Commands:
list Print a list of images kubeadm will use. The configuration file is used in case any images or image repositories are customized
pull Pull images used by kubeadm
Flags:
-h, --help help for images
Global Flags:
--add-dir-header If true, adds the file directory to the header of the log messages
--kubeconfig string The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file. (default "/etc/kubernetes/admin.conf")
--log-file string If non-empty, use this log file (no effect when -logtostderr=true)
--log-file-max-size uint Defines the maximum size a log file can grow to (no effect when -logtostderr=true). Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--one-output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
--rootfs string [EXPERIMENTAL] The path to the 'real' host root filesystem.
--skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
-v, --v Level number for the log level verbosity
Use "kubeadm config images [command] --help" for more information about a command.
# kubeadm config err
invalid subcommand: "err"
See 'kubeadm config -h' for help and examples
i have not seen complains from users about this. do all commands behave the same way or are we inconsistent?
All commands behave the same way.
For beginners, there should be more friendly prompts for some commands, e.g.: kubeadm config ...
Simple ideas :smiley: :
is this easy to change - i.e. would the cmd library that we use Cobra allow it?
yes.
you can send a pr if you'd like. something we have to preserve is the application exit status. if no sub command is passed we can print a help sceen but the status must continue to be 1.
Thanks. I will do it.