Coder Social home page Coder Social logo

cf-workshop-sb-module's Introduction

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).

cf-workshop-sb-module's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.