We can use the same binary as a standalone Service Catalog CLI, and as a kubectl plugin, with only minor modifications.
This is what you see today with svcat.
curl -sLO https://servicecatalogcli.blob.core.windows.net/cli/latest/$(uname -s)/$(uname -m)/svcat
chmod +x ./svcat
mv ./svcat /usr/local/bin/
Performs an in-place upgrade of the binary.
svcat upgrade
This is on our backlog, currently upgrading involves repeating the installation steps.
$ svcat get bindings
$ svcat sync broker osba
$ svcat unbind mysql
By adding a new svcat install-plugin
command, we can use the binary
in either standalone or plugin mode.
Flags passed to the plugin are intercepted by kubectl and are converted to environment variables:
- The flag must be defined in the manifest.
- Global kubectl flags, like
--namespace
, are converted toKUBECTL_PLUGINS_GLOBAL_FLAG_NAMESPACE
. - Command-specific flags, like
svcat provision --class
, are converted toKUBECTL_PLUGINS_LOCAL_FLAG_CLASS
.
This will install the the svcat binary and an accompanying plugin
manifest to ~/.kube/plugins/svcat/
.
curl -sLo /tmp/svcat https://servicecatalogcli.blob.core.windows.net/cli/latest/$(uname -s)/$(uname -m)/svcat
chmod +x /tmp/svcat
/tmp/svcat install-plugin
Performs an in-place upgrade of the binary and the plugin manifest.
kubectl plugin svcat upgrade
In an ideal world, the plugin
sub-command would not be necessary. When a sub-command
is used that isn't a built-in command, kubectl would search for a matching plugin,
making a command like kubectl svcat get bindings
possible. We would need
to follow-up to know if that was considered and rejected previously.
$ kubectl plugin svcat get bindings
$ kubectl plugin svcat sync broker osba
$ kubectl plugin svcat unbind mysql
Some commands are simple enough that you could use kubectl entirely, without using the plugin:
kubectl plugin svcat bind mysql
->kubectl create -f mybinding.yaml
kubectl plugin svcat unbind mysql-binding-1
->kubectl delete servicebinding mysql-binding-1
Falling back to kubectl to perform easy tasks depart from the "domain-specific tool" goal of svcatt to use the same terms when speaking
about service catalog on the command line. Rolling up multi-step concerns and tasks into
a single domain-based task. For example svcat unbind mysql-instance
, iterates all of the existing
bindings and removes them. Yes, you can do the same with kubectl, but this fits an entire concept
into a single command. It shouldn't be up to the user to know about these special cases.