Introducing a Cloud Foundry Service Broker for HP IDOL
This blog post presents a prototype of a Cloud Foundry service broker—created by our team—for HP IDOL API.
What is a service broker?
In Cloud Foundry, a service broker is an application (that can be deployed in Cloud Foundry itself or not) that supports a specific interface known as service broker API. It is called by the cloud controller to manage service instances that are then binded to the deployed applications.
There are three different actions performed by the service broker. The first action is catalog in which it announces different services and plans that the service broker is capable to provide. Most services need to instantiate something (a database, a server with a running application, etc.), that’s known as provisioning the service. At last, the service instance needs to be binded to the applications that will use it, and the cloud controller will add the required credentials to all the binded applications.
Below, we explain how we created a service broker for HP IDOL—data analytics software from Hewlett-Packard.
How to build one
Let’s write a very minimal service broker for cloud foundry using Ruby. Let’s use it to add credentials for the HP IDOL API so a deployed application can access those. It will not instantiate anything, but will only share a specific credential with the bind applications.
As a starting point, I’ve used the github-service-broker sample, but we will remove all the GitHub-related stuff.
The only action that needs an actual implementation is the binding.
class ServiceBrokerApp < Sinatra::Base put '/v2/service_instances/:instance_id/service_bindings/:id' do |instance_id, binding_id| credentials = self.class.app_settings['idol'] # get credentials from settings.yml content_type :json status 200 {"credentials" => credentials}.to_json end end
This returns the credentials that the cloud controller will then add to the environment of the binded applications.
The other actions will be quite simple, as the catalog will be a hardcoded JSON for the services and provisioning, deprovisioning and unbinding will simply do nothing and return an empty JSON with a 200 response code.
How to deploy it
Watch this video to see how to deploy the service broker we’ve written to Cloud Foundry:
For more on HP IDOL, check out its website or GitHub repository. To learn the details about creating service brokers for Cloud Foundry, refer to its documentation.
To see our prototype of the HP IDOL service broker, go to this GitHub repo.
Related video
This short video sheds some light on some of HP IDOL’s analytical capabilities.
Related reading
- Creating a Custom Cloud Foundry Buildpack from Scratch: What’s Under the Hood
- Creating a Sample Service Broker for Cloud Foundry with Python’s Flask