These instructions are written assuming you will use one of the Roadshow Sandbox Environments.
This lab will guide you through:
-
deploying a Service Broker as an app to Cloud Foundry
-
registering the Broker with the Cloud Controller
-
making the single plan in the catalog ``public''
-
creating an instance of a service
-
pushing and binding a test app to that service
-
testing the app’s interaction with the service
The Service Broker for this lab is for a service called HashMap as a Service (HaaSh). It wraps a minimal REST API around a Java HashMap implementation, and each service creation event results in a newly allocated Map.
-
Clone the haash-broker repo:
$ git clone https://github.com/mstine/haash-broker.git $ cd haash-broker
-
Build the project using Gradle Wrapper:
$ ./gradlew assemble
-
Ensure that you have targeted your bosh-lite Cloud Foundry deployment, and push the app:
$ cf push -m 512m -p build/libs/haash-broker-0.0.1-SNAPSHOT.jar haash-broker
-
Once the app is running, register the broker with the Cloud Controller (substitute the route for your broker app):
$ cf create-service-broker haash-broker warreng natedogg http://haash-broker.s#.pcf.pivotal.io
-
Next, we need to make the service plan public, as all plans start private by default.
$ cf enable-service-access haash
-
You should now be able to see your service in the marketplace:
$ cf marketplace Getting services from marketplace in org default / space development as admin... OK service plans description HaaSh basic HaaSh - HashMap as a Service
-
Next, create an instance of your service:
$ cf create-service HaaSh basic my-hash
-
Now it’s time to push and bind to the client app. First clone the haash-client repo:
$ git clone https://github.com/mstine/haash-client.git $ cd haash-client
-
Build the project using Gradle Wrapper:
$ ./gradlew assemble
-
We’ll use a CF application manifest to take care of our metadata, including binding to the HaaSh service. It’s already in the project, but you can see it reproduced here:
applications: - name: haash-client memory: 512M path: build/libs/haash-client-0.0.1-SNAPSHOT.jar services: - my-hash
This allows a simpler push experience:
$ cf push
-
Once the application is running, you can test it:
$ curl haash-client.s#.pcf.pivotal.io/HaaSh/foo -d '{"value":"bar"}' -X PUT {} $ curl haash-client.s#.pcf.pivotal.io/HaaSh/foo {"value":"bar"}
-
Congratulations! You’ve completed the lab. Don’t forget to spend some time looking at the source code for haash-broker and compare what you see to the [Service Broker API Documentation](http://docs.cloudfoundry.org/services/api.html).