Now that you have Cloud Foundry running, you'll discover it doesn't do much without some stateful services into which you will store data. Cloud Foundry supports the Open Service Broker API to allow you to integrate any compatible service broker.

Fortunately there is one service broker that you can deploy easily with BOSH 2.0 - the Docker Broker.

We will now deploy the Docker Broker to include PostgreSQL, Redis and MySQL service offerings. It is mouth watering:

$ cf marketplace
service plans description
mysql56 free MySQL 5.6 service for application development and testing
postgresql96 free PostgreSQL 9.6 service for application development and testing
redis32 free Redis 3.2 service for application development and testing

Three docker instances, with a front-facing subway instance which contains the Open Service Broker API interface.

If you've looked in bosh-deployment and cf-deployment repos you'll see a pattern in these three repos - one "just works" base manifest, and a collection optional modifier manifests. In this article's docker-broker-deployment repo, this base manifest is docker-broker.yml.

Does it work?

You can sanity test the deployment to confirm that each of the services is working as expected:

bosh run-errand sanity-test

When this is finished look carefully at the output. You'll see that postgresql96 and redis32 services actually self-tested - the Docker images that describe each service also know how to sanity test themselves.

Nice. Any Docker image you use in Docker Broker can also be used to self-test that the service is working as expected. See frodenas/docker-postgresql as an example.

Is it secure?

Yes. The Docker daemons are all protected by TLS certificates and the Broker API is protected by random password. In this article at no time will you personally need to see these passwords or certificates.

Easy helpful generation of certificates and passwords is one of the new features of bosh2 CLI, as well as the up-coming Credhub project.

Integration with Cloud Foundry

This article is about integrating the Docker Broker with Cloud Foundry. For that we redeploy the command above, but include the op-cf-integration.yml file and register the API as a Cloud Foundry Service Broker.

First, fetch the system_domain and the cf_admin_password data from the cf deployment:

Enabling access to all plans of service postgresql96 for all orgs as admin...
OK
Enabling access to all plans of service redis32 for all orgs as admin...
OK
Enabling access to all plans of service mysql56 for all orgs as admin...
OK
Getting service access as admin...
broker: docker-broker
service plan access orgs
mysql56 free all
redis32 free all
postgresql96 free all

With your cf CLI you can now see the three services ready for action:

cf marketplace

The output will as shown at the top of the article. The three -o services/op-*.yml files appear as services:

service plans description
mysql56 free MySQL 5.6 service for application development and testing
postgresql96 free PostgreSQL 9.6 service for application development and testing
redis32 free Redis 3.2 service for application development and testing