Code Monkey home page Code Monkey logo

pgo-osb's Introduction

Crunchy Data Logo

Latest Release: v1.0.0, 2024-05-22

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:

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 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=$PATH:$GOBIN
export COROOT=$GOPATH/src/github.com/crunchydata/pgo-osb
export CO_BASEOS=centos7
export CO_VERSION=1.0.0
export CO_IMAGE_TAG=$CO_BASEOS-$CO_VERSION
export CO_IMAGE_PREFIX=crunchydata
export CO_NAMESPACE=demo
export CO_CMD=kubectl

Install the dep dependency tool:

curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh

Get the deps:

Deploy Service Catalog

Install the service catalog into your Kube 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

To deploy the pgo-osb broker…​

make image
make deploy

You can 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:

make provision
kubectl get serviceinstance

You should see a pod with that service instance name:

kubectl get pod --selector=name=testinstance

Create a binding:

make bind
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

Provision an Instance

$ svcat provision -n demo myinstance --class pgo-osb-service --param CO_USERNAME=username --param CO_PASSWORD=password --param CO_CLUSTERNAME=myinstance --plan=default
  Name:        myinstance
  Namespace:   demo
  Status:
  Class:       pgo-osb-service
  Plan:        default

Parameters:
  CO_CLUSTERNAME: myinstance
  CO_PASSWORD: password
  CO_USERNAME: username

View all instances on the cluster

$ svcat describe plan pgo-osb-service/default
  Name:          default
  Description:   The default plan for the pgo osb service
  UUID:          86064792-7ea2-467b-af93-ac9694d96d5c
  Status:        Active
  Free:          true
  Class:         pgo-osb-service

Instances:
NAME      NAMESPACE   STATUS
+------------+-----------+--------+
  myinstance   demo        Ready
  testy4       demo        Ready

View Instances in a Namespace

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

Bind an Instance

$ svcat bind -n demo myinstance --name myinstance-binding
Name:        myinstance-binding
Namespace:   demo
Status:
Secret:      myinstance-binding
Instance:    myinstance

Parameters:
No parameters defined

$ svcat describe binding myinstance-binding --show-secrets

$ kubectl describe secret myinstance-binding
Name:         myinstance-binding
Namespace:    demo
Labels:       <none>
Annotations:  <none>

Type:  Opaque

Data
====
postgres:     10 bytes
primaryuser:  10 bytes
testuser:     10 bytes

Notice in this example that we have 3 Postgres users and their passwords stored in this Secret as a result of the binding being created.

pgo-osb's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.