The quintessential story for platform as a service is that the developer needn’t perform a bunch of administrative functions just to start working on their code. Have a look at the installation instructions for the developer-targeted Spring Trader reference implementation for a pre-PaaS deployment experience. In a PaaS, this lengthy guide is replaced with one command each to provision a database and a messaging service, and then another command that deploys each part of the application with bindings to these services.
Service brokers are what make this provisioning and binding happen with ease, and today we are delighted to report that Cloud Foundry partner, SAP, has open sourced a new Cloud Foundry service broker for their SAP HANA database. To round out a very compelling three-way partnership, Swisscom have deployed SAP HANA DB, Cloud Foundry and the new service broker to their infrastructure; Cloud Foundry brings the elastic runtime, SAP brings the service and Swisscom is the service provider – wholesome goodness! And finally, to exercise the service broker, Pivotal worked with another partner, Accenture, to migrate the Spring Trader (dare I say “legacy”?) application to this environment.
SAP and Swisscom developed the broker, implementing the Cloud Foundry V2 Service Broker API, and they have described this in a blog post of their own. A service broker simply implements a set of HTTP endpoints and once the endpoints are live, a
cf add-service-broker command will make the service offering available, as shown with the
cf services --marketplace command. A service instance is created with the
cf create-service command, and finally when the application is deployed it is bound to the service instance. This application deployment flow, with the SAP HANA DB service broker providing the database instance is shown in this video.
The service broker API is an important part of the Cloud Foundry landscape as it provides a simple and elegant means for drawing into the PaaS an array of capabilities, from a multitude of vendors. There is no single, one-stop shop for enterprise IT needs, so this integration strategy is absolutely essential. In addition to the set of vendors providing services on run.pivotal.io, Cloud Foundry has an impressively expanding set of partners providing service integrations for the enterprise. And, as an added bonus, this particular exercise demonstrates there is more to services integration than providing the broker alone.
Once a service is bound, the application has access to the service credentials via an environment variable, VCAP_SERVICES. The application could include code that reads and parses that variable and then uses those credentials to connect to the service; for example, using the host name, port, username and password for a database such as SAP HANA DB. While this approach works, it introduces a tight coupling between the application and its deployment environment, deep down in the code itself (making this architect really uncomfortable). A better approach would be if the application code could focus on the core application needs, and any such connectivity could be configured at deployment time.
If you are a spring developer, the spring-cloud project does just this. Spring-cloud allows you add a few entries into your application configuration and it will evaluate the runtime environment and respond appropriately. If the application is deployed to Cloud Foundry, for example, it will find and parse the VCAP_SERVICES environment variable and instantiate the right beans with the provided credentials. In the case of relational databases, this involves utilizing the right JDBC driver and Spring-cloud supports an extension mechanism for this. In addition to the broker implementation, SAP developed exactly this extension which we included alongside the application during deployment. This allowed us to configure the application for SAP HANA DB with the following entries:
<cloud:data-source id="dataSource" service-name="hdb1"> <cloud:connection properties="sessionVariables=sql_mode='ANSI';characterEncoding=UTF-8;defaultTransactionIsolation=2"/> <cloud:pool pool-size="20" max-wait-time="200"/> </cloud:data-source> <cloud:rabbit-connection-factory />
SAP have open sourced the broker implementation and announced its availability both with their blog post, as well as in a press release timed to coincide with their Bangalore TechEd event. Swisscom is the first service provider with a SAP HANA service offering on Cloud Foundry and is accepting applications for their beta program. We are delighted to be a part of this partnership that offers the next level of service to enterprise PaaS customers.
About the Author