Skip to content

Latest commit

 

History

History
121 lines (101 loc) · 2.99 KB

service-broker-lab.adoc

File metadata and controls

121 lines (101 loc) · 2.99 KB

CF Workshop Service Broker Demo

Intro

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.

Steps

  1. Clone the haash-broker repo:

    $ git clone https://github.com/mstine/haash-broker.git
    $ cd haash-broker
  2. Build the project using Gradle Wrapper:

    $ ./gradlew assemble
  3. 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
  4. 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
  5. Next, we need to make the service plan public, as all plans start private by default.

    $ cf enable-service-access haash
  6. 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
  7. Next, create an instance of your service:

    $ cf create-service HaaSh basic my-hash
  8. 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
  9. Build the project using Gradle Wrapper:

    $ ./gradlew assemble
  10. 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
  11. 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"}
  12. 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).