submariner-io / enhancements

Enhancement proposals for Submariner projects.
https://submariner.io/
Apache License 2.0
5 stars 24 forks source link

Add subctl as kubectl plugin #182

Closed Jaanki closed 9 months ago

Jaanki commented 1 year ago

A plugin is a standalone executable file, whose name begins with kubectl-. To install a plugin, move its executable file to anywhere on your PATH.

kubectl provides a command kubectl plugin list that searches your PATH for valid plugin executables.

More information can be found on extending kubectl with plugins page.

You can also discover and install kubectl plugins available in the open source using Krew. Krew works across all major platforms, like macOS, Linux and Windows.

On the surface, installing a kubectl plugin seems simple enough – all you need to do is to place an executable in the user’s PATH prefixed with kubectl- – that you may be considering some other alternatives to Krew, such as:

  1. Having the user manually download the plugin executable and move it to some directory in the PATH
  2. Distributing the plugin executable using an OS package manager, like Homebrew (macOS), apt/yum (Linux), or Chocolatey (Windows)
  3. Distributing the plugin executable using a language package manager (e.g. npm or go get)

While these approaches are not necessarily unworkable, potential drawbacks to consider include:

  1. How to get updates to users (in the case of manual installation)
  2. How to package a plugin for multiple platforms (macOS, Linux, and Windows)
  3. How to ensure your users have the appropriate language package manager (go, npm)
  4. How to handle a change to the implementation language (e.g. a move from npm to another package manager)

Krew solves these problems cleanly for all kubectl plugins, since it’s designed specifically to address these shortcomings. With Krew, after you write a plugin manifest once your plugin can be installed on all platforms without having to deal with their package managers.

Action items:

Once this is done, users would be able to install subctl via krew. Few of krew command examples are: kubectl krew install subctl kubectl krew upgrade subctl

None of the existing subctl command's behaviour will change except that they would need to be prefixed by kubectl.

$ kubectl subctl --help
An installer for Submariner

Usage:
  subctl [command]

Available Commands:
  benchmark           Benchmark tests
  cloud               Cloud operations
  completion          Generate the autocompletion script for the specified shell
  deploy-broker       Deploys the broker
  diagnose            Run diagnostic checks on the Submariner deployment and report any issues
  export              Exports a resource to other clusters
  gather              Gather troubleshooting information from a cluster
  help                Help about any command
  join                Connect a cluster to an existing broker
  recover-broker-info Recovers the broker-info.subm file from the installed Broker
  show                Show information about Submariner
  unexport            Stop a resource from being exported to other clusters
  uninstall           Uninstall Submariner and its components
  upgrade             Upgrades Submariner
  verify              Run verifications between two clusters
  version             Get version information on subctl

Flags:
  -h, --help   help for subctl

Use "subctl [command] --help" for more information about a command.

This would particularly be need to be done if and when we decide to ship subctl as part of OpenShift CLI manager.

github-actions[bot] commented 9 months ago

This PR/issue depends on: