rook / kubectl-rook-ceph

Krew plugin to run kubectl commands with rook-ceph
Apache License 2.0
81 stars 27 forks source link

Create kubectl plugin as additional tool for configuring and troubleshooting Rook #2

Closed travisn closed 3 years ago

travisn commented 3 years ago

Is this a bug report or feature request?

What should the feature do: Create a Krew plugin to extend kubectl commands for Rook.

What is use case behind this feature: kubectl plugins provide additional conveniences for running kubectl commands. This can be a very helpful tool for troubleshooting or automating steps that today are manual or not obvious to collect. This is another tool that can help supplement our documentation around advanced configuration or disaster recovery, besides some common commands to simplify the life of Rook users.

Here are some commands we might consider:

All commands would default to the rook-ceph namespace. For other namespaces pass -n <namespace>, or pick up the environment variable ROOK_NAMESPACE.

Likely we should create a new repo for this tool, no need to version it with the main Rook releases.

subhamkrai commented 3 years ago

@travisn can I take this?

Madhu-1 commented 3 years ago

Maybe add commands for cephcsi also?

BlaineEXE commented 3 years ago

Rook is not synonymous with Ceph. I think we should have the commands be kubectl ceph, kubectl rook-ceph, or make the kubectl rook plugin require a backend selection kubectl rook ceph...

subhamkrai commented 3 years ago

Rook is not synonymous with Ceph. I think we should have the commands be kubectl ceph, kubectl rook-ceph, or make the kubectl rook plugin require a backend selection kubectl rook ceph...

currently how I have implemented is kubectl will be prefix and rook will be root command which will accept 2 arguments(till now will add more as more command is added) 1 is ceph for ceph related command likekubectl rook ceph status and 2nd is operator kubectl rook operator restart

travisn commented 3 years ago

The tool really seems like it would need to be specialized for a storage provider. This would imply that each storage provider implements its own tool in its own repo. And as awkward as it is to append storage provider names to rook, it seems the tool would need to be called rook-ceph, which would mean commands such as:

Another possibility is that the storage providers get a name simply of the storage provider, and drop the rook prefix. This would give commands like:

The latter is cleaner, but we lose the naming that it belongs to rook. I'm leaning more towards the simplicity than keeping rook in the name.

As far as the repo name, the pattern for other krew plugins seems to be kubectl-<pluginName>.

BlaineEXE commented 3 years ago

I support calling it ceph also.

I think the only oddity about naming it ceph is for running ceph CLI commands. I think kubectl ceph run <command>... would be good. But not all ceph tools use the ceph CLI tool. Should we support running rbdtool/radosgw-admin also? It might be kubectl ceph run ceph status or kubectl ceph run radosgw-admin ..... We would want to allow-list the commands to run, though so people can't just run whatever they want.

travisn commented 3 years ago

What about this?

BlaineEXE commented 3 years ago

What about this?

* The tool optimizes some commands and runs them in the operator pod, no toolbox necessary:

  * `kubectl ceph status`

I think that makes some amount of sense. In reality, we may want to just pass through any unknown command as though it's a command directly to the ceph cli.

* The toolbox must already be running, and any arbitrary command can be executed there.

  * `kubectl ceph toolbox <any command that you could run in the toolbox>`:

I think toolbox already running OR we can run the command in a toolbox job. :)


For example:

subhamkrai commented 3 years ago

created this checklist from the issue so that we have the update and any new suggestion can be added here FYI @travisn @leseb @BlaineEXE @sp98 @Madhu-1 @parth-gr

BlaineEXE commented 3 years ago

I think this is a great discussion. Naming is one of the hardest problems in development, and here we are really determining what the user experience of this tool will be. Having the tool be as easy to use and understand for users is, in my opinion, the most important consideration for this development. That said, I think we have discussed 3 options for how the plugin can be named.

  1. kubectl-rook
  2. kubectl-rook-ceph
  3. kubectl-ceph

I'll list out some of the commands the use might run below, and I'll try to offer a good pro-con for all of them.

I will start with some assumptions:

  1. For running ceph CLI commands, it is best for users to make the experience as close to that documented by the Ceph docs as possible.
    • To me, this means that ... ceph <subcommand> (e.g., kubectl rook ceph osd pool ls) is the correct user experience.
    • Compare that to something like kubectl rook run <subcommand> (e.g., kubectl rook run osd pool ls)
  2. For setting operator configs, it is best for users to have a config subcommand.
    • kubectl rook operator set is unclear what is being set on the CLI, and kubectl rook operator config set is much more clear. This also follows the kubectl config ... precedent.
  3. This plugin is for Ceph only. We will not accept features to the plugin for NFS, Cassandra, or any future backends

kubectl-rook

PROS CONS
kubectl rook is a simple and clear root command This command will make the experience for future backends worse

kubectl-ceph

PROS CONS
kubectl ceph is a simple root command that won't conflict with future backend plugins
this makes running ceph commands the first-class citizen this makes running ceph commands the first-class citizen
our own subcommands may override ceph cli commands (e.g. if kubectl ceph status has a special implementation)
using kubectl ceph rook <command> to run commands to work around the above issue is more verbose

kubectl-rook-ceph

PROS CONS
kubectl rook-ceph won't conflict with future backend plugins and is the most clear it is also the most verbose root command
kubectl rook-ceph ceph <cmd> stutters with "...-ceph ceph..."
BlaineEXE commented 3 years ago

After typing out all of the above, I think the best option is to use rook-ceph as the root command. It is the most clear in my opinion, and the extra verbosity is minor.

If the verbosity is an issue for anyone, that is a very easily fixed problem using aliases. In my own environment, I would likely use alias rookctl='kubectl rook-ceph' (or alias cephctl='kubectl rook-ceph'???), and we could even suggest that to users.

[additional] I suspect that once krew is more established, kubectl will start offering tab completion of the plugin name (root command), which will help users who might have multiple rook-<backend> plugins installed if that ever happens in the future.

travisn commented 3 years ago

I'm not worried about the verbosity either of rook-ceph vs ceph. It's more about what makes the most sense for usability. From our discussion, the clarifying usability question is really the difference between a control plane command and a raw ceph command that should be run directly (either in the toolbox or operator pod). I agree that the most clear option is to call the tool rook-ceph so that everything by default is a control plane command. Then if you want a raw ceph command, we have the toolbox keyword.

I would suggest we don't even offer a kubectl rook-ceph ceph option to run a command in the operator pod. That's just an optimization. If they want a raw ceph command, it seems most usable and clear if we stick with kubectl rook-ceph toolbox <command> and require the toolbox to be running if they want to use it. Or, if the tool sees the toolbox is not running, it could run the command in the operator pod with the required config arguments.

sp98 commented 3 years ago

Have seen projects following the below format for the CLI:

<Top Level Command> <Command> <Resource> <Arguments> <Flags>

For example: Kubectl get pods -n rook-ceph

So can also have CLI commands like below :

kubectl rook-ceph get operator-config
kubectl rook-ceph get health
kubectl rook-ceph get version
kubectl rook-ceph get status 
kubectl rook-ceph get mon endpoints
kubectl rook-ceph get volumes [rwx|rwo|cephfs|rbd]

kubectl rook-ceph set pool-failure-domain <pool> <domain>
kubectl rook set mon-endpoints 
kubectl rook-ceph set operator-config <property> <value>
kubectl rook-ceph set mon-quorum <mon> 

kubectl rook restart operator

kubectl rook-ceph delete osd  <osd-id>