kubectl: kubectl clusterrole help doesn't document --user flag
What happened?
–user is missing from the list of options
$ kubectl -n security create rolebinding workloads --clusterrole workloads --help
Create a role binding for a particular role or cluster role.
Examples:
# Create a role binding for user1, user2, and group1 using the admin cluster role
kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1
Options:
--allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in
the template. Only applies to golang and jsonpath output formats.
--clusterrole='': ClusterRole this RoleBinding should reference
--dry-run='none': Must be "none", "server", or "client". If client strategy, only print the object that would be
sent, without sending it. If server strategy, submit server-side request without persisting the resource.
--field-manager='kubectl-create': Name of the manager used to track field ownership.
--group=[]: Groups to bind to the role
-o, --output='': Output format. One of:
json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.
--role='': Role this RoleBinding should reference
--save-config=false: If true, the configuration of current object will be saved in its annotation. Otherwise, the
annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
--serviceaccount=[]: Service accounts to bind to the role, in the format <namespace>:<name>
--show-managed-fields=false: If true, keep the managedFields when printing objects in JSON or YAML format.
--template='': Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
--validate=true: If true, use a schema to validate the input before sending it
Usage:
kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname]
[--serviceaccount=namespace:serviceaccountname] [--dry-run=server|client|none] [options]
Use "kubectl options" for a list of global command-line options (applies to all commands).
What did you expect to happen?
$ kubectl -n security create rolebinding workloads --clusterrole workloads --help Create a role binding for a particular role or cluster role.
Examples:
Create a role binding for user1, user2, and group1 using the admin cluster role
kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1
Options: –allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. –clusterrole=‘’: ClusterRole this RoleBinding should reference –dry-run=‘none’: Must be “none”, “server”, or “client”. If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. –field-manager=‘kubectl-create’: Name of the manager used to track field ownership. –group=[]: Groups to bind to the role -o, --output=‘’: Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file. –role=‘’: Role this RoleBinding should reference –save-config=false: If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. –serviceaccount=[]: Service accounts to bind to the role, in the format <namespace>:<name> –show-managed-fields=false: If true, keep the managedFields when printing objects in JSON or YAML format. –template=‘’: Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. –user=[]: Users to bind to the role –validate=true: If true, use a schema to validate the input before sending it
Usage: kubectl create rolebinding NAME --clusterrole=NAME|–role=NAME [–user=username] [–group=groupname] [–serviceaccount=namespace:serviceaccountname] [–dry-run=server|client|none] [options]
Use “kubectl options” for a list of global command-line options (applies to all commands).
How can we reproduce it (as minimally and precisely as possible)?
$ kubectl -n internal create rolebinding workloads --clusterrole workloads —help | | grep ‘--user’ Nothing saying what the --user flag does.
Anything else we need to know?
No response
Kubernetes version
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:41:01Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:34:54Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}
Cloud provider
OS version
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, …) and versions (if applicable)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (16 by maintainers)
@Shubham82 that was what I was thinking, then mark
--user
(the non-global one) as deprecated, and print a warning if people are using that flag, telling them to use--role-user
instead. That way we can someday (afters several future releases) remove the--user
from this command.BUT… I think this should be discussed with SIG-CLI though before doing that, perhaps in the next bug scrub meeting, or in the next regular SIG-CLI meeting.
There is probably a bigger overall issue of “how do we handle/fix shadowed flags”
A quick look and I see (at least) these commands shadow
--user
with their own flag:In fact,
config set-context
shadows--user
,--cluster
, and--namespace
flags. This might be fine though because the global flags would be meaningless for that command.The real problem is that shadowed flags don’t show up in the help output, so maybe another, different solution would be to figure out how to force them to show up in the help output even though they are shadowing a global flag. Is that possible?
IMO
role-user
is sound better. let’s wait for other opinions on it.