Enhancing Cloud Foundry with CLI Plugins Jonathan Berkhahn, IBM @jberkhahn Simon Leung, IBM @_simonleung
What are Cloud Foundry CLI Plugins? An extensible framework to add novel functionality and value to the Cloud Foundry Command Line Interface Allow CF users, developers, admins to add new commands Arbitrary functionality; interact with CF or infrastructure on top Plugin framework for interaction between plugin and CLI Golang Binary Implements the CLI plugin interface Documentation and examples available at github.com/cloudfoundry/cli/plugin_examples
What can CLI Plugins be used for? Users interacting with apps Managing app deployment, i.e. blue-green deploy Interacting with apps directly Admins interacting with CF deployments Updating configuration of CF resources Developers testing new CF features Testbed for up and coming new features Development tools for ease of use
Plugin Use Case: CF Stack-Changer Lucid version of Ubuntu being sunset Many container backends running on CF use Lucid Every running app on a Cloud Foundry needs to be switched Without Plugins Switch every app manually Writing a script isn’t much better Heavy-duty scripting to hit all the apps under all the orgs on an entire Cloud Foundry Script has to be distributed to multiple possible environments
CF Stack-Changer
Plugin Use Case: V3_Beta Version 3 of the CF API being rolled out experimentally New endpoints, abstractions for pushing, listing apps Volatile API as development continues 3 Without Plugins Write curl requests manually Hard to keep up with evolving API
V3_Beta Easier than manually writing curl requests Easier to distribute than scripts Easy to update the plugin when the API changes
Distributing CLI Plugins
How would users discover and install my plugins? Distributing? How would users discover and install my plugins?
Problem: Hassle to download Discovering the plugin Binary file Problem: Hassle to download Discovering the plugin > cf install-plugin <PLUGIN_BINARY>
Problem: Discovering the plugin From URL Problem: Discovering the plugin > cf install-plugin <URL_TO_PLUGIN>
Plugin Repository Find and install plugins with only 2 commands! cf repo-plugins cf install-plugin
What is a plugin repository? A server that CLI interact with to browse and install plugins Multiple repos can be tracked.
2 repositories being tracked by CLI
What is a plugin repository? A server that CLI interact with to browse and install plugins Multiple repos can be tracked. Anyone can host a plugin repo.
Clone and start hosting your own repository http://github.com/cloudfoundry-incubator/cli-plugin-repo
Run repo and add URL to CLI
What is a plugin repository? A server the CLI interact with to browse and install plugins Multiple repos can be tracked. Anyone can host a plugin repo. Users find/install plugin without leaving CLI
Install plugin directly from repository
Bonus: Creating a plugin
Plugin Minimum Implementation GetMetadata() Meta data for all commands in the plugin Run() Entry point for plugin main function main() bootstrapping the plugin object `plugin.Start(OBJECT)` Show code
Run() GetMetadata() Main()
Questions?
Plugin Examples https://github.com/cloudfoundry/cli/tree/master/plugin_examples https://github.com/simonleung8/cli-plugin-examples