Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

vmware-archive/cf-workshop-sb-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

CF Workshop Service Broker Lab

Intro

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.54.235.203.95.xip.io
  5. Next, we need to make the service plan public, as all plans start private by default. This step is a little more manual than the others. First, you need to gain access to the Service Plan GUID:

    $ cf curl /v2/service_plans -X 'GET'
    {
      "total_results": 1,
      "total_pages": 1,
      "prev_url": null,
      "next_url": null,
      "resources": [
        {
          "metadata": {
            "guid": "ec1da994-eba0-4f50-9453-e00b155a938b",
            "url": "/v2/service_plans/ec1da994-eba0-4f50-9453-e00b155a938b",
            "created_at": "2014-06-26T19:59:02+00:00",
            "updated_at": "2014-06-26T20:00:50+00:00"
          },
          "entity": {
            "name": "basic",
            "free": true,
            "description": "Basic Plan",
            "service_guid": "d458ac57-993a-40cf-925c-d56934a0e494",
            "extra": null,
            "unique_id": "1",
            "public": false,
            "service_url": "/v2/services/d458ac57-993a-40cf-925c-d56934a0e494",
            "service_instances_url": "/v2/service_plans/ec1da994-eba0-4f50-9453-e00b155a938b/service_instances"      }    }
      ]
    }

    You find the Plan GUID at resources.metadata.guid. Next you’ll send a request to update it:

    $ $ cf curl /v2/service_plans/ec1da994-eba0-4f50-9453-e00b155a938b -X 'PUT' -d '{"public":true}'
    {
      "metadata": {
        "guid": "ec1da994-eba0-4f50-9453-e00b155a938b",
        "url": "/v2/service_plans/ec1da994-eba0-4f50-9453-e00b155a938b",
        "created_at": "2014-06-26T19:59:02+00:00",
        "updated_at": "2014-06-27T13:21:50+00:00"
      },
      "entity": {
        "name": "basic",
        "free": true,
        "description": "Basic Plan",
        "service_guid": "d458ac57-993a-40cf-925c-d56934a0e494",
        "extra": null,
        "unique_id": "1",
        "public": true,
        "service_url": "/v2/services/d458ac57-993a-40cf-925c-d56934a0e494",
        "service_instances_url": "/v2/service_plans/ec1da994-eba0-4f50-9453-e00b155a938b/service_instances"
      }
    }
  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.54.235.203.95.xip.io/HaaSh/foo -d '{"value":"bar"}' -X PUT
    {}
    
    $ curl haash-client.54.235.203.95.xip.io/HaaSh/foo -X GET
    {"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).

About

Service Broker Module for CF Community Workshops

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published