Spring Cloud has introduced a new framework called Spring Cloud App Broker that aims to ease the development of Spring Boot applications that implement the Open Service Broker API, and the provisioning of those applications as managed services.
The Open Service Broker API enables developers to provide "backing services" to applications running on cloud native platforms like Kubernetes and Cloud Foundry. The key component of this API is the Service Broker. A Service Broker manages the lifecycle of services, and the broker provides commands to fetch the catalog of services that it offers, provision and de-provision instances of the services, and bind and unbind applications to the service instances. Cloud native platforms can interact with the Service Broker to provision and gain access to the managed services offered by a Service Broker. For those familiar with OSGI, the Open Service Broker API is similar in spirit to the OSGI services, service references and service registry.
Spring Cloud App Broker is an abstraction layer on top of Spring Cloud Open Service Broker and provides opinionated implementations of the corresponding interfaces. The Spring Cloud Open Service Broker is itself a framework used to create Service Brokers and manage services on platforms that support the Open Service Broker API.
Spring Cloud App Broker can be used to quickly create Service Brokers using externalized configurations specified through YAML or Java Properties files. To get started, create a Spring Boot application and include the App Broker dependency to the project’s build file. For projects that use Gradle as the build tool, the following dependency should be added:
dependencies {
api 'org.springframework.cloud:spring-cloud-starter-app-broker-cloudfoundry:1.0.1.RELEASE'
}
For illustration, say you want to define and advertise a service that provides Natural Language Understanding (NLU) features like intent classification and entity extraction, you would include the configuration using properties under spring.cloud.openservicebroker as shown in this snippet:
spring:
cloud:
openservicebroker:
catalog:
services:
- name: mynlu
id: abcdef-12345
description: A NLU service
bindable: true
tags:
- nlu
plans:
- name: standard
id: ghijk-678910
description: A standard plan
free: true
Include the Spring Cloud App Broker configuration using properties under spring.cloud.appbroker as shown in this snippet:
spring:
cloud:
appbroker:
services:
- service-name: mynlu
plan-name: standard
apps:
- name: nlu-service
path: classpath:mynlu.jar
deployer:
cloudfoundry:
api-host: api.mynlu.com
api-port: 443
default-org: test
default-space: development
Utilizing these configurations, Spring Cloud App Broker will take care of advertising the NLU service, and it will manage the provisioning and binding of the service.
The project’s documentation describes the various service configuration options, customizations and deployment options. Note that as of now, Spring Cloud App Broker supports only Cloud Foundry as a deployment platform.