Skip to content

JamesClonk/compose-broker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

✨ compose-broker 🎲

CircleCI License Platform

Conquer the Data Layer

Performance and reliable data layers for developers who'd rather spend their time building apps than managing databases.

compose-broker is a Compose.io service broker for Cloud Foundry and Kubernetes

It supports databases and services such as:

Usage

Deploy service broker to Cloud Foundry

  1. create an API Token on your Compose.io account
  2. pick a Cloud Foundry provider. I'd suggest the Swisscom AppCloud
  3. push the app, providing the API key and a username/password to secure the service broker with
  4. register the service broker in your space (--space-scoped)
  5. check cf marketplace to see your new available service plans

create service broker

Provision new databases

  1. create a new service instance (cf cs)
  2. bind the service instance to your app (cf bs), or create a service key (cf csk)
  3. inspect the service binding/key, have a look at the credentials (cf env/cf sk)
  4. use the given credentials to connect to your new database
  5. enjoy!

provision service

Configuration

All configuration of the service broker is done through environment variables (provided by manifest.yml during a cf push) and the included catalog.yml.

manifest.yml

Possible configuration values are:

BROKER_LOG_LEVEL: info # optional, can be set to debug, info, warning, error or fatal, defaults to info
BROKER_LOG_TIMESTAMP: false # optional, add timestamp to logging messages (not needed when deployed on Cloud Foundry), defaults to false
BROKER_SKIP_SSL_VALIDATION: false, # optional, disables SSL certificate verification for API calls, defaults to false
BROKER_AUTH_USERNAME: broker-username # required, HTTP basic auth username to secure service broker with
BROKER_AUTH_PASSWORD: broker-password # required, HTTP basic auth password to secure service broker with
BROKER_CATALOG_FILENAME: catalog.yml # optional, filename containing all catalog information, defaults to catalog.yml
COMPOSE_API_URL: https://api.compose.io/2016-07/ # optional, Base URL of Compose.io API, defaults to https://api.compose.io/2016-07
COMPOSE_API_TOKEN: e7fb89a0-26f8-4ee5-890e-3c68079b15ea # required, Compose.io API Token
COMPOSE_API_DEFAULT_DATACENTER: gce:europe-west1 # optional, defaults to aws:eu-central-1
COMPOSE_API_DEFAULT_ACCOUNT_ID: 586eab527c65836dde5533e8 # optional, service broker will try to read it from Compose.io API if not set

catalog.yml

The service brokers provided catalog.yml configures all available services offerings and plans. (See OSBAPI spec)

Adjust this file to define your own different service plans with different deployment sizes / units. A plan's metadata allows for optionally configuring custom unit sizes, enabling/disabling Redis' cache mode, specifying explicit software versions or the datacenter to host the deployment.

Review the included Redis example plans for these properties:

- id: 355ef4a4-08f5-4764-b4ed-8353812b6963
name: default
description: Redis
free: false
bindable: true
metadata:
displayName: Redis
imageUrl: https://compose.com/assets/icd-icons/redis-0db857f1c0f8cb148d60407f9952c8c12e3a88f16f798a352117e5522ea234b6.svg
costs:
- amount:
usd: 18.50
unit: Monthly
bullets:
- 256 MB Storage
- 256 MB RAM
highAvailability: true
units: 1
- id: ae2bda53-fe15-4335-9422-774aae3e7e32
name: cache
description: Redis
free: false
bindable: true
metadata:
displayName: Redis
imageUrl: https://compose.com/assets/icd-icons/redis-0db857f1c0f8cb148d60407f9952c8c12e3a88f16f798a352117e5522ea234b6.svg
costs:
- amount:
usd: 31.50
unit: Monthly
bullets:
- 512 MB Storage
- 512 MB RAM
highAvailability: true
# Number of resource units to allocate to the deployment (optional, defaults to 1)
units: 2
# Whether to optimize the deployment to be used as a cache (optional, Redis only)
cache_mode: true
# Version of the software to deploy (optional)
version: "4.0.14"
# Datacenter to use for deployment (optional, defaults to $COMPOSE_API_DEFAULT_DATACENTER)
datacenter: aws:eu-central-1

Plan metadata example:
metadata:
  # Number of resource units to allocate to the deployment (optional, defaults to 1)
  units: 2
  # Whether to optimize the deployment to be used as a cache (optional, Redis only)
  cache_mode: true
  # Version of the software to deploy (optional)
  version: "4.0.14"
  # Datacenter to use for deployment (optional, defaults to $COMPOSE_API_DEFAULT_DATACENTER)
  datacenter: aws:eu-central-1

Account ID & Datacenter

By default the service broker will provision new database deployments with the configured account id COMPOSE_API_DEFAULT_ACCOUNT_ID and datacenter COMPOSE_API_DEFAULT_DATACENTER (see manifest.yml). If no account id is configured it will try to read the value over the Compose.io API and take the first account it finds. Similarly if no datacenter is configured it will use aws:eu-central-1 as default value.

When issuing service provisioning requests to the service broker it is possible to provide the account id and/or the datacenter as additional parameters.

Example:
cf create-service etcd default my-etcd -c '{
  "account_id": "454f3deb8cad236ffb3452e9", 
  "datacenter": "gce:europe-west1"
}'

Units

When issuing service provisioning requests to the service broker it is also possible to request a specific unit size (which basically determines the scaling for your Compose.io deployments, memory and disk space) instead of the configured value in the service brokers catalog.yml.

It is also possible to update existing service instances with cf update-service.

Example:
cf create-service scylla default my-scylla-db -c '{ "units": 10 }'
# or
cf update-service my-postgres-db -c '{ "units": 4 }'

Version

Last but not least it is also possible during service provisioning to request specific software versions for your database deployments. You can get all available versions from the Compose.io API: https://api.compose.io/2016-07/databases

Example:
cf create-service rethink default my-rethinkdb -c '{ "version": "2.3.7" }'