Skip to content

Latest commit

 

History

History
102 lines (68 loc) · 3.75 KB

README.adoc

File metadata and controls

102 lines (68 loc) · 3.75 KB

Service Brokers

Goal

In this section, students will deploy a custom service broker.

  1. The haash-broker implements a HashMap as a Service

  2. Deploy the Service Broker as an app to Cloud Foundry

  3. Register the Broker with the Cloud Controller

  4. Make the single plan in the catalog “public” in your organization

  5. Create an instance of your service

  6. Push and bind a test app to your service instance

  7. Test the app’s interaction with the service

Exercise

  1. Review the documentation on Creating Custom Services. Pay paticular attention to the service broker API.

Overview

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.

The source for the broker can be found here. It was originally written by Matt Stine and modified for our needs

You do not need to build the code, a jar is provided below.

haash-broker

  • Download the hash broker

  • Push the broker as an app to CF. Use the name: <first-initial><last-initial>-haash-broker

  • Register the broker with the cloud controller, you will need an admin (Josh, but pretend I’m your IT department) to help you out. Information required for this command can be found from the catalog endpoing (/v2/catalog)

    $ cf create-service-broker ...

    The username & password you need for the broker are warreng/natedogg (regulate!)

Brokers need a unique ID and name to be used in CF, to achieve this we use the time you pushed the app

  • Next, you need to make the plan public:

    $ cf enable-service-access ...

    You will need to figure out the service id (and optionally plan id). You can do this by accessing your service broker’s catalog from a browser or the cli. <broker url>/v2/catalog and look in the services array ("HaaSh"). For this class, we’ve used the time you pushed the app as the id.

  • Verify you can see your new service in the marketplace. There is a cf command for this

  • Create a new instance of your service using the CF commands. Name the instance <first-initial><last-initial>-haash-service.

Haash Client

  • Create a manifest for your haash-client.

  • Be sure to connect the haash-client to the service instance you created above.

  • Download the haash-client from S3.

  • Push the haash-client to PCF and name it: <first-initial><last-initial>-haash-client

  • Curl your haash client to be sure it is working and using your haash-service

    You can add key,value pairs using:

    $ curl <your haash-client>/HaaSh/<key> -d '<some value>' -X PUT
  • You can retrieve the values:

    $ curl <your haash-client>/HaaSh/<key>

Beyond the class

There are many community resources to help you build your own more robust service broker.