Difficulty: beginner
Estimated Time: 15-20 minutes

Web applications are not always completely stateless and would usually use a database for storing data which needs to be shared between instances of the web application.

The ability of OpenShift to provide persistent storage means that you can deploy a database along side the web application. This database would only be visible within the same project as the web application, however it still should be secured with a database password.

In this course you will learn how to deploy a web application, along with a database for storing data entered via the web application. You will then update the deployment configuration for the web application configuration so that the database credentials will be passed to the web application.

The environment used for this course is based on OpenShift 3.7, with service catalog and template service broker enabled. The features used to bind the database to the web application are not present in older versions of OpenShift.

In this course you learnt how with the new service catalog and builtin in template service broker for OpenShift 3.7, you can easily deploy a database and then bind it to an application.

Any details of a provisioned service are stored in a Secret and can be injected into an application using environment variables or through a volume mount. The application code then need only check for these and use them when connecting to the service, such as the database which was used in this course.

For more details on the service catalog and template service broker see:

Binding a Database to an Application

Step 1 of 6

Topic 1 - Creating an Initial Project

Before we get started, you need to login and create a project in OpenShift to work in.

To login to the OpenShift cluster used for this course from the Terminal, run:

oc login -u developer -p developer

This will log you in using the credentials:

  • Username: developer
  • Password: developer

You should see the output:

Login successful.

You don't have any projects. You can try to create a new project, by running

    oc new-project <projectname>

To create a new project called myproject run the command:

oc new-project myproject

You should see output similar to:

Now using project "myproject" on server "".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git

to build a new example application in Ruby.

Switch to the Dashboard and login to the OpenShift web console using the same credentials you used above.

Web Console Login

This should leave you at the service catalog. You should also see listed to the right the project myproject which you created.

Service Catalog