# Database setup

Use the IBM Cloud console to launch the OpenShift web console

![web console](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2Fdd055cc9d075a6f9155e098fb5caa737cb1b744a.png?generation=1600695207795110\&alt=media)

First create an 'Example Bank' namespace

![create project](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F04bfa31c05c9da42e7d5409f4667c4289ca62a19.png?generation=1600695209571493\&alt=media)

From the navigation menu on the left select **Operators** --> **OperatorHub**

![operatorhub](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F3a96b65292e6d1e1c0eab01a724b8b17c7157184.png?generation=1600695207529583\&alt=media)

Type 'Postgres' into the search bar, and select the **PostgreSQL Operator by Dev4Ddevs.com** tile.

![postgres operator](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2Fc168d7a491e1202369239b0ee52f000dc51e293b.png?generation=1600695209938694\&alt=media)

Click **Continue** to show the community operator and then **Install**

![install operator](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F29fde370890ed0958f9015076eca27a6bf16c8ef.png?generation=1600695212001169\&alt=media)

Be sure you are installing the Operator in the `Example Bank` namespace, and click **Subscribe**

![subscribe](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F60832720eca36ea5278ecd3f69edb671a8066215.png?generation=1600695208326509\&alt=media)

Status will show "Succeeded: Up to date" when complete

![succeeded](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F60832720eca36ea5278ecd3f69edb671a8066215.png?generation=1600695208326509\&alt=media)

Use the very top drop down in the navigation menu on the left to switch to _Developer\*_ view

![developer view](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F0ab4e0c0478ca5c4918d855dbb90ef35dd7642a9.png?generation=1600695209066818\&alt=media)

Click **+Add** and select the Database tile

![add database](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F994d00ec8ac3edbfd2b3f3fb66848c3e64ca9bfa.png?generation=1600695210590632\&alt=media)

Choose the **Database Database** tile and then **Create**

![database](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2Fc33bd27f8ef79657995436f50e1c83f91941f03d.png?generation=1600695211262772\&alt=media)

You can edit some of the specifics of the database here. For example, change the name to `creditdb` and click **Create**

![create database](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F99619c780cdfec28a1843a5a172393f7a38da7ab.png?generation=1600695210401346\&alt=media)

Switch to the Topology tab, and watch your database creation complete!

![topology](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2Fb210f7f1fec3c82cba5ce32b34a09191afa8521c.png?generation=1600695208436089\&alt=media) Use the very top drop down in the navigation menu on the left to switch to _Developer\*_ view

![developer view](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F0ab4e0c0478ca5c4918d855dbb90ef35dd7642a9.png?generation=1600695209066818\&alt=media)

Click **+Add** and select the Database tile

![add database](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F994d00ec8ac3edbfd2b3f3fb66848c3e64ca9bfa.png?generation=1600695210590632\&alt=media)

Choose the **Database Database** tile and then **Create**

![database](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2Fc33bd27f8ef79657995436f50e1c83f91941f03d.png?generation=1600695211262772\&alt=media)

You can edit some of the specifics of the database here. For example, change the name to `creditdb` and click **Create**

![create database](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F99619c780cdfec28a1843a5a172393f7a38da7ab.png?generation=1600695210401346\&alt=media)

Switch to the Topology tab, and watch your database creation complete!

![topology](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2Fb210f7f1fec3c82cba5ce32b34a09191afa8521c.png?generation=1600695208436089\&alt=media)

Now we will need some CLI access. First, go to [https://labs.cognitiveclass.ai](https://labs.cognitiveclass.ai) and start a **Theia - Cloud IDE (With OpenShift)** session

![cognitiveclass](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2Fa70fb968c96c9df1342a8e30ca04c47f683b659d.png?generation=1600695210877190\&alt=media)

back on your OpenShift web console, click you email address in the upper right corner and choose **Copy Login Command**

![copy login command](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F337313f54f197d3d59a4a541801b7b0fe6f7bb76.png?generation=1602170885060615\&alt=media)

From the resulting screen, grab your login credentials, and copy them into your ClognitiveClass terminal

![clusterlogin](https://3928126737-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHI9hQsrkpOgN4dX6Cj%2Fsync%2F5567057f878d51d048eb65269e1a29183a597206.png?generation=1600695207278319\&alt=media)

switch to the example bank project:

```
oc project example-bank
```

Create a secret so the script that loads the schema can access the database

```
kubectl create secret generic bank-db-secret --from-literal=DB_SERVERNAME=creditdb --from-literal=DB_PORTNUMBER=5432 --from-literal=DB_DATABASENAME=example --from-literal=DB_USER=postgres --from-literal=DB_PASSWORD=postgres
```

Run the job to create the schema

```
oc apply -f data_model/job.yaml
```

![schema](https://raw.githubusercontent.com/IBM/example-bank/main/images/schema-1.png)

Verify that the schema load succeeded:

```
oc logs cc-schema-load-<pod>
```

Now that the database is ready, we can build and deploy the remaining microservices.
