|
| 1 | +--- |
| 2 | +id: meshstack.meshmarketplace.broker-tutorial |
| 3 | +title: Tutorial: Implement a Broker |
| 4 | +--- |
| 5 | + |
| 6 | +:::note What is this guide about? |
| 7 | +This tutorial walks you through setting up a service broker that deploys services using CI/CD tools you already know. You'll learn about the Open Service Broker API, available libraries, and practical recommendations for implementation and testing. |
| 8 | +::: |
| 9 | + |
| 10 | +## Prerequisites |
| 11 | + |
| 12 | +- Familiarity with cloud-native platforms and basic service provisioning concepts. |
| 13 | +- Access to a CI/CD pipeline and a supported programming language (Java, Go, .NET, or Python). |
| 14 | +- Understanding of your organization's requirements for service lifecycle management. |
| 15 | + |
| 16 | +## Step by Step Guide |
| 17 | + |
| 18 | +### 1. Understand the Open Service Broker API |
| 19 | + |
| 20 | +The [Open Service Broker API](https://www.openservicebrokerapi.org/) enables software vendors and developers to provide backing services to workloads running on cloud-native platforms. It defines a set of RESTful endpoints for provisioning, binding, and managing service offerings. |
| 21 | + |
| 22 | +- One broker can host multiple services. |
| 23 | +- The API supports synchronous and asynchronous provisioning. |
| 24 | +- Service brokers can add features like billing and backup/restore. |
| 25 | + |
| 26 | +### 2. Choose an Implementation Approach |
| 27 | + |
| 28 | +You can start with an existing project or library, or build your own broker from scratch. |
| 29 | + |
| 30 | +#### Quickstarts |
| 31 | + |
| 32 | +- **[Unipipe Service Broker](https://github.com/meshcloud/unipipe-service-broker):** |
| 33 | + Example implementation that connects to a Git repository for catalog and instance management. Integrates with CI/CD pipelines. |
| 34 | +- **[Spring Boot & Groovy OSB API](https://github.com/openservicebrokerapi/servicebroker):** |
| 35 | + For Java/Spring developers. |
| 36 | +- **[osb-service-broker-example](https://github.com/evoila/osb-example):** |
| 37 | + Cloud Foundry-focused, requires custom logic for your service. |
| 38 | +- **[osb-starter-pack](https://github.com/pmorie/osb-starter-pack):** |
| 39 | + Go-based starter for rapid prototyping. |
| 40 | + |
| 41 | +#### Libraries |
| 42 | + |
| 43 | +- **Java:** |
| 44 | + [Spring Cloud Open Service Broker](https://spring.io/projects/spring-cloud-open-service-broker) |
| 45 | + [spring-cloud-app-broker](https://github.com/spring-cloud/spring-cloud-app-broker) |
| 46 | +- **Go:** |
| 47 | + [brokerapi](https://github.com/pivotal-cf/brokerapi) |
| 48 | + [osb-broker-lib](https://github.com/pmorie/osb-broker-lib) |
| 49 | + [Cloud service broker](https://github.com/pivotal/cloud-service-broker/) |
| 50 | +- **.NET:** |
| 51 | + [Open Service Broker API for .NET](https://github.com/AXOOM/OpenServiceBroker) |
| 52 | +- **Python:** |
| 53 | + [openbrokerapi](https://pypi.org/project/openbrokerapi/) |
| 54 | + |
| 55 | +### 3. Implement the Required Endpoints |
| 56 | + |
| 57 | +Each service broker must implement the OSBAPI endpoints: |
| 58 | + |
| 59 | +- **Catalog:** Returns the list of services and plans. |
| 60 | +- **Provision:** Creates a new service instance. |
| 61 | +- **Bind/Unbind:** Connects/disconnects applications to service instances. |
| 62 | +- **Deprovision:** Deletes a service instance. |
| 63 | + |
| 64 | +Follow the [OSBAPI specification](https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md) closely for request/response formats and error handling. |
| 65 | + |
| 66 | +### 4. Test Your Service Broker |
| 67 | + |
| 68 | +- Use the [API Swagger documentation](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/openservicebrokerapi/servicebroker/v2.16/openapi.yaml#/) to understand and test endpoints. |
| 69 | +- Try the [eden CLI](https://starkandwayne.com/blog/welcome-to-eden-a-cli-for-every-open-service-broker-api/) for local development and testing. |
| 70 | +- Consider the [osb-checker tool](https://github.com/openservicebrokerapi/osb-checker) for compliance checks. |
| 71 | + |
| 72 | +### 5. Integrate with meshStack and CI/CD |
| 73 | + |
| 74 | +- If using Unipipe, connect your broker to a Git repository and configure your CI/CD pipeline to manage service instances. |
| 75 | +- For other implementations, ensure your broker is reachable by meshStack and supports the required endpoints. |
| 76 | + |
| 77 | +### 6. Maintain and Evolve Your Broker |
| 78 | + |
| 79 | +- Use consistent IDs for services and plans. |
| 80 | +- Implement proper error handling and support both synchronous and asynchronous operations. |
| 81 | +- Plan for deprecation and removal of services or plans. |
| 82 | +- Support multiple bindings per instance and create separate credentials for each binding. |
| 83 | +- Provide admin endpoints for handling error states and orphaned resources. |
| 84 | + |
| 85 | +:::tip |
| 86 | +Check out the [OSB API Compliant Service Brokers](https://www.openservicebrokerapi.org/compliant-service-brokers) catalog for inspiration and reference implementations. |
| 87 | +::: |
| 88 | + |
| 89 | +## Related Resources |
| 90 | + |
| 91 | +### Concepts |
| 92 | + |
| 93 | +- [OSB Services](new-concept-osb-services.md) |
| 94 | +- [Marketplace](new-concept-marketplace.md) |
| 95 | + |
| 96 | +### Guides |
| 97 | + |
| 98 | +- [How to Manage OSB Services](new-guide-how-to-manage-osb.md) |
| 99 | +- [How to Manage a Project](new-guide-how-to-manage-a-project.md) |
| 100 | +- [How to Manage a Workspace](new-guide-how-to-manage-a-workspace.md) |
0 commit comments