Skip to content
This repository has been archived by the owner on Apr 1, 2021. It is now read-only.

vshn/crossplane-service-broker-poc

Repository files navigation

Crossplane Service Broker POC

POC Code to provide an Open Service Broker API which provisions Redis and MariaDB instances via crossplane.

See the production implementation: https://github.com/vshn/crossplane-service-broker

Usage

Starting the broker

export KUBECONFIG=/path/to/kubeconfig
OSB_USERNAME=test OSB_PASSWORD=TEST OSB_SERVICE_ID=id make run

Testing

eden can be used to test the OSB integration.

$ export SB_BROKER_URL=http://localhost:8080
$ export SB_BROKER_USERNAME=test
$ export SB_BROKER_PASSWORD=TEST

List Catalog

$ eden catalog
Service     Plan          Free         Description
=======     ====          ====         ===========
redis-helm  redis-large   unspecified
~           redis-medium  unspecified
~           redis-small   unspecified

Provision Service

$ export SB_INSTANCE=my-test-redis
$ eden provision -s redis-helm -p redis-small

Bind Service

$ eden bind --instance my-test-redis
# output will contain a CLI to retrieve the credentials, execute that
$ eden credentials #...

Update instance

# ensure to either export or replace the $INSTANCE_UUID/SERVICE_UUID/PLAN_UUID variable:
$ curl -X PATCH 'http://localhost:8080/v2/service_instances/'"$INSTANCE_UUID" -u test:TEST -v -d '{"service_id": "'$SERVICE_UUID'", "plan_id": "'$PLAN_UUID'"}' -H 'X-Broker-API-Version: 2.13'

Custom APIs

This implementation contains a couple of custom APIs, not defined by the OSB spec.

Get endpoints

# ensure to either export or replace the $INSTANCE_UUID variable:
$ curl 'http://localhost:8080/custom/service_instances/$INSTANCE_UUID/endpoint' -u test:TEST -v|jq

Development

If the env var KUBECONFIG is set, it will be used to connect to downstream clusters instead of the actual provider config. This helps to debug locally since downstream clusters are usually not accessible from a workstation.