I need a simple way to create and delete (and ultimate upgrade) dedicate services - redis, postgresql, etc. In this post I introduce a simple CLI for creating a Redis server, getting the URI for the service, binding it to your Cloud Foundry app, and later deleting it.
Here is an example scenario for installing the plugin, login to bosh (ask your sysadmin for credentials), uploading the redis release to bosh, and then creating and deleting as many redis servers as you and your team need.
$ gem install bosh_cli -v "~> 1.5.0.pre" --source https://s3.amazonaws.com/bosh-jenkins-gems/ $ gem install bosh_cli_plugin_redis $ bosh prepare redis $ bosh create redis $ bosh show redis uri redis://:firstname.lastname@example.org:6379/0 $ cf set-env myapp REDIS_URI redis://:email@example.com:6379/0 $ cf unset-env myapp REDIS_URI $ bosh delete redis
The source for the CLI plugin is at https://github.com/drnic/bosh_cli_plugin_redis.
The source for running redis upon bosh is https://github.com/cloudfoundry-community/redis-boshrelease.
Where is redis server described?
When you run
bosh prepare redis above, the bosh release that describes redis is uploaded to your bosh. There is no cloning git repositories or creating bosh releases. It quickly pulls down a bosh package and a bosh job that describe running redis and upload them to your bosh.
In future, each new plugin version may include new improvements to the bosh release. You run
bosh prepare redis each time you install a new plugin gem.
Of note are three files in the bosh release:
redis.conftemplate is in jobs/redis/templates/config/redis.conf.erb
- the monit control script is in jobs/redis/templates/bin/redis_ctl
- the packaging/compilation script for redis-server is in packages/redis/packaging
How is redis server and properties described?
Put simply, the plugin is automating the creation of a bosh deployment file (and deploying/deleting it). So anything you can do with bosh you can do with do here.
bosh create redis creates a
deployments/redis/redis-123456.yml deployment file in the local folder (say an application folder).
So you can edit it and run
bosh deploy to make any fancy changes. Also, future versions of the plugin will provide ways to update or scale any given redis service to make that simpler.
The plugin uses the current
bosh deployment to determine which redis deployment it is functioning on.
How are instance sizes described?
You'll note in the example above that
--size medium is used to describe the size of the server to run redis. In AWS there is no
medium instance flavor; nor might your OpenStack have a instance flavor
You might ask "how do I specify an m1.medium on AWS?" or "how do I use the instances sizes my OpenStack administrator has given me?"
In the initial release of the plugin there are four instance sizes supported -
xlarge - and these map to different things on different infrastructures. By default, in AWS and OpenStack, they map to instance flavors
Soon it will be entirely configurable what instance sizes are available and how they map to instance flavors on your infrastructure.
Known limitations of current v0.2 release
- no public IP support - so can only access the redis server from other bosh deployments (such as Cloud Foundry) from the same bosh (via its internal DNS)
- there is no
bosh update redisyet, although you can modify the generated deployment file and run
- it only includes default aws & openstack templates - to add support for vsphere please add templates into redis-boshrelease first
- no way yet to customize the list of available instance sizes
These are all fixable limitations. I'm sorry if you're adversely affected by them today.
The idea of using ERb templates to generate the large bosh deployment files, and the idea of managing the experience from the
cf command line come from the bootstrap-cf-plugin.
I prefer this tool as a
bosh CLI plugin than a
cf CLI plugin. Its performing tasks upon bosh. In future I would like a service available to
cf users which adheres to cf user roles and organizations/spaces and provisions/destroys services such as redis via bosh.
I don't like that this plugin, nor bootstrap-cf-plugin, nor bosh-cloudfoundry must exist. Ultimately I want any bosh release to be very easy to use without an additional CLI plugin.