Latest Release: v1.1.0, 2024-12-30
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:
-
[Open Service Broker API](https://github.com/openservicebrokerapi/servicebroker)
-
[
osb-broker-lib
](https://github.com/pmorie/osb-broker-lib). -
[
go-open-service-broker-client
](https://github.com/pmorie/go-open-service-broker-client) -
[service-catalog](https://github.com/kubernetes-incubator/service-catalog)
-
pgo-osb 1.1.0 works with Postgres Operator 3.3.0
-
pgo-osb 1.0.0 works with Postgres Operator 3.2.0
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.
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
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 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
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.
$ svcat get brokers NAME URL STATUS +---------+-------------------------------------------+--------+ pgo-osb http://pgo-osb.demo.svc.cluster.local:443 Ready
$ svcat get classes NAME DESCRIPTION +-----------------+--------------+ pgo-osb-service The pgo osb!
$ 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
$ svcat get instances -n demo NAME NAMESPACE CLASS PLAN STATUS +------------+-----------+-----------------+---------+--------+ testinstance demo pgo-osb-service default Ready testy4 demo pgo-osb-service default Ready