Part 2 – Backend as a Service – proof of concept
This is the second in a four-part series of posts running you through a proof of concept we have been working on at UKCloud to deliver backend services to support the public sector. In part two below we will be using the dataservices that we setup in part one.
For the demo, we have a single virtual machine with the postgres client pre-installed and an Open Service Broker CLI to remove the complexity of interfacing with the REST API. You can access the CLI here.
Step 1 – Authenticating
We need to tell the client to target our service broker endpoint and pass in the credentials for authentication.
sb t http://postgresql-service-broker.service.dc1.consul:3000
sb login
Step 2 – Querying the catalogue
In order to understand what services we can deploy via the broker we need to query the service broker catalogue
sb marketplace
This will return the plan details, for example:
Step 3 – Deploy a service
Once we have chosen our plan we can request our new service via the service broker.
sb create-service a9s-postgresql94 postgresql-single-small bfd8a05c-6b93-11e7-907b-a6006ad3dba0
The UUID at the end is a unique reference that we generate for the service name to avoid naming conflicts.
We can query the status of the deployment by running:
sb service bfd8a05c-6b93-11e7-907b-a6006ad3dba0
This will return:
Step 4 – Create binding details
Once deployed we need to create some access credentials. We do this by creating a service key which will pass us back all the endpoint details.
sb create-service-key bfd8a05c-6b93-11e7-907b-a6006ad3dba0 my-app-creds
Which returns:
Finally to test the deployment we can login and write data to the new database.
service-broker-cli]$ psql -U a9sc718927f190d5aea9beda9d6a7e0f0ba93edf733 -h d71321b-psql-master-alias.node.dc1.consul -d d71321b
Which will give us a command prompt to the postgres database that we deployed.
So within a couple of minutes we have access to highly available database services which our application can start consuming.
Whilst this is cool it starts getting even easier when we integrate PaaS, see part 3 for details.