Feature request: Allow spaces in plugin names in order to enable sub-commands
kubectl allows plugins with spaces in the name to provide the user experience of sub-commands:
a plugin that wishes to be invoked whenever the command
kubectl foo bar bazis invoked by the user, would have the filename ofkubectl-foo-bar-baz
krew does not allow for this option, because it uses .metadata.name for the plugin name, and this cannot have spaces. Any hyphens in the name get translated to underscores in the filename, which kubectl translates back to hyphens in the command name.
This could be resolved by having an optional field in the Plugin YAML, .spec.command which could be set to an array of strings much like the spec.containers.command field in a Kubernetes Pod. For example:
apiVersion: krew.googlecontainertools.github.com/v1alpha3
kind: Plugin
metadata:
name: foo-bar-baz
spec:
command: ["foo", "bar", "baz"]
Whats your need for this?This is an intentional design choice because we install a single symlink.
I don't understand why would you install a subcommand just by itself instead of installing the main command itself.
The main rationale for this is that krew should be able to manage any valid kubectl plugin, which is currently not the case.
My specific need is that we have developed a set of plugins based on subcommands of kubectl node - so, kubectl node pods to get the pods running on a node, kubectl node os to show the operating system, etc. Each plugin is a separate script, and we would like to manage these plugins with krew. This is only possible by implementing this feature request.
Which "kubectl node" command are you referring to? Does the kubectl core now allow adding plugins to arbitrary builtin subcommands?
Does the kubectl core now allow adding plugins to arbitrary builtin subcommands?
Yes - please see the link and example in my first comment on this issue.
I don't think you can add subcommands to a builtin command (except for "create")?
Is there actually a "kubectl node" command, if not, we don't grant a name like that to a 3rd party plugin to begin with in krew-index.
Is there actually a "kubectl node" command, if not, we don't grant a name like that to a 3rd party plugin to begin with in krew-index.
There is no "kubectl node" command, but that's not relevant because we do not want to add it to the krew-index - these are plugins we want to use within our company and we want to use krew to manage their installation via a custom index.
As you point out, subcommands can legitimately be added to "kubectl create" and therefore this is still an issue that needs addressing even if not using a custom index.