Overview Link to heading
This is the first of a series of posts around the service catalog. The end goal is to demonstrate how the service catalog can simplify building apps on kubernetes and openshift.
The first part will cover:
- why
- how to install
- how to use
The target environment will be openshift 3.10 on Linux using `oc cluster up` for development purposes.
Introduction Link to heading
Working with kubernetes since its early days, there are countless of times where I had to go into creating manifests for the services my application is using. By services I am referring to things like databases, messaging systems, or any other pieces of third party software my application might need.
Each time, the process is the same:
- Find a suitable docker image.
- Search for matching manifests.
- Try out.
- Rinse and repeat.
And even when all things are in place I have to find a way of letting my application know `how to connect` to the service. And of course, this only applies to services that are running `side by side` with the application.
What about external services?
The service catalog is a solution that brings service brokers as defined by the open service broker api to kubernetes.
It provides a couple of new kind of resources that define:
- service broker
- service types
- service instances
- service bindings
If you want to familiarize yourself with the purpose of those, please check the qm
Preparation Link to heading
To manipulate the service catalog resources from the command line you will need the service catalog client.
The service catalog client Link to heading
You will need to `svcat` binary to interact with the catalog from the command line.
On my linux machine this can be done:
|
|
Full instructions (for all operating systems) can be found in the service catalog installation guide.
Preparing the environment Link to heading
Installing the service catalog Link to heading
I will be using for openshift 3.10 which I’ll start directly using:
|
|
Then I just need to add the service catalog and a broker:
|
|
Validating the setup Link to heading
To make sure everything is fine let’s list the available brokers:
|
|
The output should contain `openshift-automation-broker`.
Provision a service: Link to heading
Now, lets create the database. I’ll be using microsoft sql server. So let’s see what the broker we installed has to offer:
|
|
If not obvious, this will list all the available classes and plans for ms sql server (classes refer to the service type and plan refers to the different flavors e.g. persistent).
|
|
Our database should be provisioned soon. Now all we need to do is to create a binding that our application will use to connect to the service.
Binding to the service Link to heading
|
|
What this actually does is that it create a new `Secret` with all the connection information and it also creates a `ServiceBinding` which binds the instance we created with the secret. Any piece of code that needs to connect to the service we created can use the secret (in whatever way its preferable).
In the next part of this series we will introduce you to a tool that allows spring boot applications to automagically connect to service catalog managed services.
Stay tuned !