Introducing Spring Cloud App Broker

贺雅健
2023-12-01

Engineering
Roy Clarkson
May 30, 2019

We recently announced the general availability of Spring Cloud Services 3.0, which involved a major redesign of the previous architecture used in that project. As detailed in the related blog post, Spring Cloud Services has moved to the latest versions of Spring Framework and Spring Boot, and is now built on a Reactive programming model and Spring WebFlux. Two key components of this redesign are offered as open source Spring Cloud projects.

The first project is Spring Cloud Open Service Broker. This project has been available for some time; however, the recent 3.0.0 release has itself been redesigned to incorporate a Reactive programming model and updated to support Spring WebFlux.

The second project, which is being introduced today, is Spring Cloud App Broker. Spring Cloud App Broker represents an abstraction of a significant piece of the underlying architecture in Spring Cloud Services, and we are pleased to announce that Spring Cloud App Broker 1.0.1 is now available.
Background

The Open Service Broker API project allows developers to deliver services to applications running within cloud native platforms such as Cloud Foundry, Kubernetes, and OpenShift. To date, the only option for building a Spring Boot based service broker application has been to add the Spring Cloud Open Service Broker starter to your project, include the required configuration, and implement the required interfaces. Spring Cloud Open Service Broker is less opinionated about service broker implementation and leaves many of those decisions to the developer, requiring the developer to implement all of the service broker application logic themselves.
Introduction

Spring Cloud App Broker is also a framework for building Spring Boot applications that implement the Open Service Broker API. It provides a framework based on Spring Boot that enables the developer to quickly create a service broker that deploys applications and services to the platform when managed services are provisioned. It builds on Spring Cloud Open Service Broker by offering opinionated implementations of the Spring Cloud Open Service Broker interfaces.

What does this mean in practical terms? Imagine that the managed services that are deployed by a service broker have a dependency on additional services or applications. Utilizing App Broker configuration properties, these services and applications can be declared and the dependencies defined. When the service broker receives a request to provision a new service instance, App Broker will manage the deployment or provisioning of dependent apps and services, and bind those services and apps where appropriate. Conversely, when a request is received to delete a service instance, App Broker will unbind and delete any dependent services and applications that were previously provisioned.
Getting Started

Create a Spring Boot application and include the Spring Cloud App Broker dependency in the application’s build file.
Maven Dependencies

Include the following in your application’s pom.xml file:

org.springframework.cloud spring-cloud-starter-app-broker-cloudfoundry 1.0.1.RELEASE

Gradle Dependencies

Include the following in your application’s build.gradle file:

dependencies {
compile ‘org.springframework.cloud:spring-cloud-starter-app-broker-cloudfoundry:1.0.1.RELEASE’
}

Configuring the Service Broker

The service broker is configured using Spring Boot externalized configuration, supplied using a YAML or Java Properties file (for example, you can provide configuration in the application.yml file). Because Spring Cloud App Broker builds on Spring Cloud Open Service Broker, you must provide Spring Cloud Open Service Broker configuration in order to use Spring Cloud App Broker.

Include Spring Cloud Open Service Broker configuration using properties under spring.cloud.openservicebroker, as in the following example:

spring:
cloud:
openservicebroker:
catalog:
services:
- name: example
id: ebca66fd-461d-415b-bba3-5e379d671c88
description: A useful service
bindable: true
tags:
- example
plans:
- name: standard
id: e19e6bc3-37c1-4478-b70f-c7157ebbb28c
description: A standard plan
free: true

Include Spring Cloud App Broker configuration using properties under spring.cloud.appbroker, as in the following example:

spring:
cloud:
appbroker:
services:
- service-name: example
plan-name: standard
apps:
- name: example-service-app1
path: classpath:app1.jar
- name: example-service-app2
path: classpath:app2.jar
deployer:
cloudfoundry:
api-host: api.sys.example.com
api-port: 443
username: admin
password: adminpass
default-org: test
default-space: development

Service Instances

Backing apps and dependent services can be configured for one or more services that are managed by a service broker by using the following properties.
App Deployment Properties

Properties for a backing app can be configured as default for all app deployments, or each service’s backing app deployment may be configured individually. See the reference documentation for a more comprehensive list of available properties.

spring:
cloud:
appbroker:
deployer:
cloudfoundry:
properties:
memory: 1G
health-check: http
health-check-http-endpoint: /health
health-check-timeout: 180

Set overriding values for a specific service in the service’s configuration under spring.cloud.appbroker.services.*, as shown in the following example:

spring:
cloud:
appbroker:
services:
- service-name: example
plan-name: standard
apps:
- name: example-service-app1
path: classpath:app1.jar
properties:
memory: 2G
count: 2
no-route: true

Service Configuration

A backing app may require one or more dependent services. For example, an app may require the use of a MySQL database. App Broker will create any configured services and bind them to the associated app. Services are configured using properties under services for the deployed app, as in the following example:

spring:
cloud:
appbroker:
services:
- service-name: example
plan-name: standard
apps:
- name: example-service-app1
path: classpath:app1.jar
services:
- service-instance-name: example-db
name: mysql
plan: small
parameters:
param-key: param-value

Further Customization

In addition to the supported configuration described above, Spring Cloud App Broker offers further methods of customizing the process of provisioning service instances. For example, App Broker can generate and assign unique credentials for each backing app deployment through the use of customized credential providers.

Workflows are also provided for the various stages of creating, updating, and deleting service instances, and for creating and deleting service instance bindings. For example, CreateServiceInstanceWorkflow can be implemented and configured as a Spring Bean within the application to hook additional functionality into the request to create a service instance. This may be as simple as processing specific logging requirements.
Conclusion

Building functional service brokers can be challenging, but with the availability of projects such as Spring Cloud Open Service Broker and Spring Cloud App Broker, we are hoping to reduce the amount of boilerplate code and enable you to more quickly build your own service broker.
comments powered by Disqus

translate:
翻译:

我们最近宣布了Spring Cloud Services 3.0的全面可用性,其中涉及对该项目中使用的先前架构的重大重新设计。如相关博客文章中所述,Spring Cloud Services已迁移到最新版本的Spring Framework和Spring Boot,并且现在基于Reactive编程模型和Spring WebFlux构建。重新设计的两个关键组件是作为开源Spring Cloud项目提供的。

第一个项目是Spring Cloud Open Service Broker。这个项目已经有一段时间了。但是,最新的3.0.0版本本身已经过重新设计,以包含Reactive编程模型,并进行了更新以支持Spring WebFlux。

今天要介绍的第二个项目是Spring Cloud App Broker。 Spring Cloud App Broker代表了Spring Cloud Services中很大一部分基础架构的抽象,我们很高兴地宣布Spring Cloud App Broker 1.0.1现在可用。
背景

Open Service Broker API项目允许开发人员向在Cloud Foundry,Kubernetes和OpenShift等云原生平台内运行的应用程序提供服务。迄今为止,构建基于Spring Boot的Service Broker应用程序的唯一选择是将Spring Cloud Open Service Broker入门程序添加到您的项目中,包括所需的配置并实现所需的接口。 Spring Cloud Open Service Broker对服务代理实现的看法较少,将许多决策留给了开发人员,要求开发人员自己实现所有服务代理应用程序逻辑。
介绍

Spring Cloud App Broker还是用于构建实现Open Service Broker API的Spring Boot应用程序的框架。它提供了一个基于Spring Boot的框架,该框架使开发人员可以快速创建服务代理,当提供托管服务时,该服务代理将应用程序和服务部署到平台。它通过提供Spring Cloud Open Service Broker接口的可靠实现来建立在Spring Cloud Open Service Broker的基础上。

这实际上意味着什么?想象一下,由服务代理部署的托管服务依赖于其他服务或应用程序。利用App Broker配置属性,可以声明这些服务和应用程序并定义依赖项。当服务代理收到提供新服务实例的请求时,App Broker将管理从属应用程序和服务的部署或供应,并在适当时绑定这些服务和应用程序。相反,当收到删除服务实例的请求时,App Broker将取消绑定并删除以前配置的任何相关服务和应用程序。
入门

 类似资料:

相关阅读

相关文章

相关问答