Skip to content

Open Service Broker Implementation Based on the Crunchy PostgreSQL Operator

License

Notifications You must be signed in to change notification settings

andrewlecuyer/pgo-osb

 
 

Repository files navigation

Crunchy Data Logo

Latest Release: v1.1.0, 2024-12-28

General

The pgo-osb project is an implementation of the Open Service Broker API. This implementation uses the Crunchy PostgreSQL Operator as a means to provision services, in this case the service is a PostgreSQL database cluster.

pgo-osb allows users to also bind to a service instance which when invoked will return PostgreSQL credentials to a user they can use to connect to the PostgreSQL database instance.

Also, users can deprovision a PostgreSQL database cluster using the OSB API.

The pgo-osb broker was developed using the OSB Starter Pack and associated libraries.

See the following:

Compatibility

  • pgo-osb 1.1.0 works with Postgres Operator 3.3.0

  • pgo-osb 1.0.0 works with Postgres Operator 3.2.0

Prerequisites

golang 1.9 or above is required to build this project.

Running the pgo-osb service broker assumes you have deployed the PostgreSQL Operator to your namespace that you will be deploying the service broker into. See https://github.com/CrunchyData/postgres-operator for documentation on deploying the PostgreSQL Operator.

This example assumes you have created a Kube namespace called demo. Adjust CO_NAMESPACE to suit your specific namespace value. The example also assumes you are using the PostgreSQL Operator default RBAC account called username with a password of password. If this is not the case then you will need to adjust the example service instance service-instance.yaml.

Build

To build the pgo-osb broker, place these additional environment variables into your .bashrc as they are used in the various scripts and deployment templates:

export GOPATH=$HOME/odev
export GOBIN=$GOPATH/bin
export PATH=$GOBIN:$PATH
export OSB_NAMESPACE=demo
export OSB_CMD=kubectl
export OSB_ROOT=$GOPATH/src/github.com/crunchydata/pgo-osb
export OSB_BASEOS=centos7
export OSB_VERSION=1.1.0
export OSB_IMAGE_TAG=$OSB_BASEOS-$OSB_VERSION
export OSB_IMAGE_PREFIX=crunchydata

Install the dep dependency tool:

mkdir $GOPATH/bin $GOPATH/src/github.com/crunchydata $GOPATH/pkg -p
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh

Get the code:

cd $GOPATH/src/github.com/crunchydata
git clone https://github.com/crunchydata/pgo-osb.git
cd pgo-osb

Deploy Service Catalog

Install the service catalog into your Kubernetes cluster by following this link:

Instructions on that link are provided to also install the very useful svcat utility for inspecting and working with the service catalog.

Warning
we have found issues using Helm 2.10 when installing Service Catalog, we tend to use Helm 2.9.1.

Deploy

Deploy the pgo-osb broker:

make setup
make image
make deploy

Verify your deployment has been successful with:

kubectl get pod --selector=app=pgo-osb
NAME                       READY     STATUS    RESTARTS   AGE
pgo-osb-69c76578b9-v7s9k   1/1       Running   0          16m

Test

To test the pgo-osb broker…​

Create an instance:

cd $OSB_ROOT
make provision
kubectl get serviceinstance
make provision2
kubectl get serviceinstance

You should see a pod with that service instance name:

kubectl get pod --selector=name=testinstance
kubectl get pod --selector=name=testinstance2

Create a binding:

make bind
kubectl get servicebinding
make bind2
kubectl get servicebinding

You can view the binding and the generated Postgres credentials using this command:

$ svcat describe binding testinstance-binding
  Name:        testinstance-binding
  Namespace:   demo
  Status:      Ready - Injected bind result @ 2018-08-24 13:44:29 +0000 UTC
  Secret:      testinstance-binding
  Instance:    testinstance

Parameters:
  No parameters defined

Secret Data:
  secrets    111 bytes
  services   151 bytes
[osb@kube11 pgo-osb]$ svcat describe binding testinstance-binding --show-secrets
  Name:        testinstance-binding
  Namespace:   demo
  Status:      Ready - Injected bind result @ 2018-08-24 13:44:29 +0000 UTC
  Secret:      testinstance-binding
  Instance:    testinstance

Parameters:
  No parameters defined

Secret Data:
  secrets    [{"data":{"postgres":"mu7BDsFi3X","primaryuser":"FHhQwZAeot","testuser":"My2g9BxjFD"},"name":"somesecretname"}]
  services   [{"name":"testinstance","spec":{"clusterIP":"10.104.162.117","externalIPs":[""],"ports":[{"name":"postgres","port":5432,"targetPort":0}]},"status":""}]

You can also use the svcat Service Catalog CLI to inspect the service catalog.

View the Service Brokers

$ svcat get brokers
NAME                        URL                      STATUS
+---------+-------------------------------------------+--------+
pgo-osb   http://pgo-osb.demo.svc.cluster.local:443   Ready

Get the Service Class

$ svcat get classes
NAME         DESCRIPTION
+-----------------+--------------+
pgo-osb-service   The pgo osb!

View the Service Class

$ svcat describe class pgo-osb-service
Name:          pgo-osb-service
Description:   The pgo osb!
UUID:          4be12541-2945-4101-8a33-79ac0ad58750
Status:        Active
Tags:
Broker:        pgo-osb
		      Plans:
		      NAME              DESCRIPTION
		+---------+--------------------------------+
		default   The default plan for the pgo
		osb service

View Instances in a Namespace

$ svcat get instances -n demo
NAME      NAMESPACE        CLASS         PLAN     STATUS
+------------+-----------+-----------------+---------+--------+
  testinstance   demo        pgo-osb-service   default   Ready
  testy4       demo        pgo-osb-service   default   Ready

Cleanup Examples

You can remove the bindings and instances using these commands:

$ svcat unbind testinstance
deleted testinstance-binding
$ svcat unbind testinstance2
deleted testinstance2-binding
$ svcat deprovision testinstance
deleted testinstance
$ svcat deprovision testinstance2

About

Open Service Broker Implementation Based on the Crunchy PostgreSQL Operator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 91.9%
  • Shell 5.0%
  • Makefile 2.6%
  • Smarty 0.5%