Deploy Database For Hero Microservice
Last updated
Last updated
Make sure that you're in Developer perspective, project userX-super-heroes is selected, and in the Topology page. Then right click in view area and select Database menu.
Select PostgreSQL database.
Click Instantiate Template button.
Enter following inputs (leave it as is for other fields) then click Create button.
Database Service Name: heroes-db
PostgreSQL Connection Username: superman
PostgreSQL Connection Password: superman
PostgreSQL Database Name: heroes_database
Wait for awhile, the heroes-db pod should be up and running.
We need to load some data into the database we've just deployed. How to do that? the answer is using PostgreSQL client to execute a SQL script. Let's do it!
Click on the Web Terminal icon located at top right corner of web console. Then select userX-super-heroes and click Start button.
Wait for a few moment, you should see a terminal shows up.
Use curl
command to download SQL script.
Sample output:
Use psql
(PostgreSQL client) to connect to the heroes-db
PostgreSQL server. The password is superman
.
Sample output:
Execute the SQL script with this command:
Sample output:
Use \dt
command to check if a new table gets created.
Sample output:
Query number of rows in the table.
Sample output:
Use \q
command to disconnect from PostgreSQL server.
The heroes-db entity in UI will change immediately. Click on it then go to Details tab. You should be able to see the labels were added.
You can minimize or close the Web Terminal window when not use it.
How to deploy PostgreSQL database service from Developer Catalog.
How to use Web Terminal via OpenShift web console to interact with application deployed on cluster (in this case, heroes-db PostgreSQL) without having to install terminal applications i.e. PuTTY, Cmder, Xshell, SecureCRT etc. on your computer.
How to use curl
command to download file from website.
How to use psql
(PostgreSQL client) command to connect to PostgreSQL database server and a few tasks e.g. run SQL script, list tables, and run SQL statement.
Run following command in Web Terminal to add a few to heroes-db workload.
How to add labels to workload using oc
- .