https://github.com/deis/steward-framework
Go SDK for the Service Catalog Controller API
https://github.com/deis/steward-framework
Last synced: about 1 year ago
JSON representation
Go SDK for the Service Catalog Controller API
- Host: GitHub
- URL: https://github.com/deis/steward-framework
- Owner: deis
- License: mit
- Created: 2016-10-26T17:57:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-10T21:00:53.000Z (about 9 years ago)
- Last Synced: 2024-06-21T14:20:57.324Z (almost 2 years ago)
- Language: Go
- Homepage:
- Size: 484 KB
- Stars: 6
- Watchers: 18
- Forks: 3
- Open Issues: 19
-
Metadata Files:
- Readme: README-OLD.md
- License: LICENSE
Awesome Lists containing this project
README
# The Steward Framework [](https://travis-ci.org/deis/steward-framework)
This repository contains the Steward Framework for creating service catalog controllers.
The framework utilizes inversion of control, implementing all the core concerns of a service catalog controller, whilst delegating implementation-specific operations to the client library.
The framework implements all of the following concerns:
* __Service catalog publishing:__ The framework publishes `servicecatalogentries` that reflect a backing service broker's offerings into the Kubernetes cluster. The query for the backing service broker's offerings is delegated to the backing service broker through the client library's implementation of the `framework.Cataloger` interface.
* __Event and control loops:__ The framework watches the Kubernetes event stream for changes to `ServicePlanClaims`. Events that trigger discreet provision, bind, unbind, or deprovision actions delegate those operations to the backing service broker through the client library's implementation of the `framework.Lifecycler` interface.
* __API server__: At this time, the API server implements only a health-check endpoint at `/healthz`.
## Implementation guide
Utilizing the Steward Framework to implement your own service catalog controller requires the following steps:
1. Include the `github.com/deis/steward-framework` package in your project using your dependency management system of choice-- for example, [glide](https://github.com/masterminds/glide) or [godeps](https://github.com/tools/godep).
2. Implement the `framework.Cataloger` and `framework.Lifecycler interfaces`. For your convenience, those interfaces are shown below:
```go
type Cataloger interface {
List(
ctx context.Context,
serviceBrokerSpec framework.ServiceBrokerSpec,
) ([]*framework.Service, error)
}
type Lifecycler interface {
Provision(
ctx context.Context,
serviceBrokerSpec framework.ServiceBrokerSpec,
req *framework.ProvisionRequest,
) (*framework.ProvisionResponse, error)
Bind(
ctx context.Context,
serviceBrokerSpec framework.ServiceBrokerSpec,
req *framework.BindRequest,
) (*framework.BindResponse, error)
Unbind(
ctx context.Context,
serviceBrokerSpec framework.ServiceBrokerSpec,
req *framework.UnbindRequest,
) error
Deprovision(
ctx context.Context,
serviceBrokerSpec framework.ServiceBrokerSpec,
req *framework.DeprovisionRequest,
) (*framework.DeprovisionResponse, error)
GetOperationStatus(
ctx context.Context,
serviceBrokerSpec framework.ServiceBrokerSpec,
req *framework.OperationStatusRequest,
) (*framework.OperationStatusResponse, error)
}
```
3. Import `github.com/deis/steward-framework/runner`
4. In your `main()` function, call the blocking `runner.Run(...)`. For convenience, the signature of that function is shown below:
```go
func Run(
cataloger framework.Cataloger,
lifecycler framework.Lifecycler,
maxAsyncDuration time.Duration,
apiPort int,
) error
```
## Example code
The following annotated example is adapted from [steward-cf](https://github.com/deis/steward-cf):
```go
import "github.com/deis/steward-framework/runner"
// ...
func main() {
// A configuration object is built from environment variables.
cfg := ...
// Relevant implementations of the framework.Cataloger and
// framework.Lifecycler interfaces are initialized.
cataloger, lifecycler := ...
// Configuration details, cataloger, and lifecycler are passed to runner.Run().
// The Steward Framework takes it from there. The call to runner.Run() will
// block infinitely or until the framework encounters a fatal error.
if err = runner.Run(
cataloger,
lifecycler,
cfg.getMaxAsyncDuration(),
cfg.APIPort,
); err != nil {
logger.Criticalf("error running steward-framework: %s", err)
}
```