Deploy applications by using the Red Hat OpenShift web console and CLI tools.
Use the Red Hat OpenShift web console to troubleshoot a failing application.
Outcomes
Deploy a database by using a container image in the Web Console.
Deploy an application with a container image by using the oc command.
Debug the application's failure by using the Web Console.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start deploy-review
This command creates the deploy-review project in the Red Hat OpenShift Container Platform (RHOCP) cluster.
Instructions
This Lab uses two services, a PostgreSQL database and an application that connects to the database.
In the following table you can find the required parameters to create the intended Quarkus application.
| Database Service Name |
postgresql
|
| PostgreSQL Connection Username |
developer
|
| PostgreSQL Connection Password |
test
|
| PostgreSQL Database Name |
todo_list
|
| Application Name |
todo-list
|
| Application Image |
registry.ocp4.example.com:8443/redhattraining/openshift-dev-deploy-review-todo-list
|
Log in to RHOCP and select the developer perspective.
Deploy the internal Postgresql database by using a Template in the Web Console.
Click to open the Add page.
Under the card, click .
![]() |
Type postgresql in the input.
Select the PostgreSQL (Ephemeral) template.
In the side panel that opens, click .
![]() |
Use the required parameters to complete the form.
![]() |
Click to start the database deployment.
In the topology view, verify that the postgresql database is running after a few seconds.
The postgresql icon must display a dark blue circle, which indicates that the database pod is running.
![]() |
Use the oc command to deploy the application's container image and create a route.
Run the oc login command with the developer user and the developer password.
[student@workstation ~]$ oc login -u developer -p developer \
https://api.ocp4.example.com:6443
Login successful.
...output omitted...Ensure that you are on the deploy-review project.
[student@workstation ~]$ oc project deploy-review
...output omitted...Run the oc new-app command with the container image URL parameter.
[student@workstation ~]$ oc new-app --name=todo-list \
registry.ocp4.example.com:8443/redhattraining/openshift-dev-deploy-review-todo-list
--> Found container image 25bd8d5 ...
...output omitted...
--> Success
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose service/todo-list'
Run 'oc status' to view your app.You can safely ignore pod security warnings for exercises in this course. OpenShift uses the Security Context Constraints controller to provide safe defaults for pod security.
Create the route for the application by using the oc expose command:
[student@workstation ~]$ oc expose service/todo-list
route.route.openshift.io/todo-list exposedTest the application and verify that it does not work.
Retrieve the list of items by running the following command:
[student@workstation ~]$ curl -s \
http://todo-list-deploy-review.apps.ocp4.example.com/todos
...output omitted...
<h1>Application is not available</h1>
...output omitted...Use the Web Console to browse the application's logs to find out the root cause of the failure.
Use the oc command to delete all the application's objects.
Use the oc command to deploy the application by adding the DB_PASSWORD environmental variable with the correct password test, and create the applications's route.
Run the oc new-app command with the container image URL parameter.
[student@workstation ~]$ oc new-app -e DB_PASSWORD=test --name=todo-list \
registry.ocp4.example.com:8443/redhattraining/openshift-dev-deploy-review-todo-list
--> Found container image 7ac26b7 ...
...output omitted...
--> Success
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose service/todo-list'
Run 'oc status' to view your app.Create the route for the application by using the oc expose command:
[student@workstation ~]$ oc expose service/todo-list
route.route.openshift.io/todo-list exposedVerify that the issue is fixed and that the application responds correctly.
Test that the application can create items.
[student@workstation ~]$ curl -i -H "Content-Type: application/json" \
http://todo-list-deploy-review.apps.ocp4.example.com/todos \
--data '{ "task": "do laundry" }'
HTTP/1.1 201 Created
...output omitted...Retrieve the list of items by running the following command:
[student@workstation ~]$ curl -s \
http://todo-list-deploy-review.apps.ocp4.example.com/todos; echo
[{"id":1,"task":"do laundry"}]