Navigate the OpenShift web console to identify CPU-consuming workloads.
Troubleshoot and fix a failed MySQL pod.
Manually scale an application.
Configure health probes.
Outcomes
You should be able to troubleshoot malfunctioning workloads, configure deployments, and scale applications.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that all resources are available for this exercise.
The command also creates the compreview-scale project and deploys some applications in that project.
The command creates the /home/student/DO180/labs/compreview-scale/resources.txt file.
The resources.txt file contains the URLs of your OpenShift cluster and the name of the images that you use during the exercise.
You can use the file to copy and paste these URLs and image names.
[student@workstation ~]$ lab start compreview-scale
Specifications
The API URL of your OpenShift cluster is https://api.ocp4.example.com:6443, and the oc command is already installed on your workstation machine.
The URL of the OpenShift web console is https://console-openshift-console.apps.ocp4.example.com. When you access the web console, select as the authentication mechanism.
Log in to the OpenShift cluster as the developer user with the developer password.
The password for the admin user is redhatocp.
Perform the following tasks to complete the comprehensive review:
A pod in the cluster is consuming excessive CPU and is interfering with other tasks. Identify the pod and remove its workload.
The compreview-scale project already includes a web application at http://frontend-compreview-scale.apps.ocp4.example.com.
When you access this URL, the application returns a list of quotations from famous authors.
The application is broken for now, and is missing some configuration to be ready for production.
The application uses two Kubernetes Deployment objects.
The frontend deployment provides the application web pages, and relies on the quotesdb deployment that runs a MySQL database.
The lab command already created the services and routes that connect the application components and that make the application available from outside the cluster.
Fix the application and make it ready for production:
The quotesdb deployment in the compreview-scale project starts a MySQL server, but the database is failing.
Review the logs of the pod to identify and then fix the issue.
Use the following parameters for the database:
| Name | Value |
|---|---|
| Username |
operator1
|
| Password |
redhat123
|
| Database name |
quotes
|
You security team validated a new version of the MySQL container image that fixes a security issue.
The new container image is registry.ocp4.example.com:8443/rhel9/mysql-80:1-237.
Update the quotesdb deployment to use this image.
Ensure that the database redeploys.
The classroom setup copied the image from the Red Hat Ecosystem Catalog.
The original image is registry.redhat.io/rhel9/mysql-80:1-237.
Add a probe to the quotesdb deployment so that OpenShift can detect when the database is ready to accept requests.
Use the mysqladmin ping command for the probe.
Add a second probe that regularly verifies the status of the database.
Use the mysqladmin ping command as well.
Configure CPU and memory usage for the quotesdb deployment.
The deployment needs 200 millicores of CPU and 256 MiB of memory to run, and you must restrict its CPU usage to 500 millicores and its memory usage to 1 GiB.
Add a probe to the frontend deployment so that OpenShift can detect when the web application is ready to accept requests.
The application is ready when an HTTP request on port 8000 to the /status path is successful.
Add a second probe that regularly verifies the status of the web front end.
The front end works as expected when an HTTP request on port 8000 to the /env path is successful.
Configure CPU and memory usage for the frontend deployment.
The deployment needs 200 millicores of CPU and 256 MiB of memory to run, and you must restrict its CPU usage to 500 millicores and its memory usage to 512 MiB.
Scale the frontend application to three pods to accommodate for the estimated production load.
To verify your work, access the http://frontend-compreview-scale.apps.ocp4.example.com URL. The application returns a list of quotations from famous authors.
Use the OpenShift web console to identify and then delete the pod that consumes excessive CPU.
Use a web browser to access the https://console-openshift-console.apps.ocp4.example.com URL.
Select , and then log in as the admin user with the redhatocp password.
Click if the message is displayed.
Switch to the perspective and then navigate to → .

Select the dashboard, and then click in the graph.

Set the zoom to five minutes and then hover over the graph.
Notice that the interface lists the compreview-scale-load namespace in the first position, which indicated that this namespace is the first CPU consumer.

Navigate to → and then select the dashboard.
Select the compreview-scale-load namespace and then set the time range to the last five minutes.
The computeprime deployment is the workload that consumes excessive CPU.

Navigate to → and then select the compreview-scale-load project.
Select the menu for the computeprime deployment and then click .
Click to confirm the operation.

Review the logs of the pod that is failing for the quotesdb deployment.
Set the missing environment variables in the quotesdb deployment.
Log in to the OpenShift cluster from the command line.
[student@workstation ~]$oc login -u developer -p developer \https://api.ocp4.example.com:6443Login successful. ...output omitted...
Set the compreview-scale project as the active project.
[student@workstation ~]$ oc project compreview-scale
...output omitted...List the pods to identify the failing pod from the quotesdb deployment.
The names of the pods on your system probably differ.
[student@workstation ~]$oc get podsNAME READY STATUS RESTARTS AGE frontend-5fb85b4c75-5s7xr 0/1 CrashLoopBackOff 14 (2m52s ago) 50mquotesdb-9b9776479-4z4g90/1 CrashLoopBackOff 14 (3m4s ago) 50m
Retrieve the logs for the failing pod. Some environment variables are missing.
[student@workstation ~]$oc logs quotesdb-=> sourcing 20-validate-variables.sh ... You must either specify the following environment variables:9b9776479-4z4g9MYSQL_USER(regex: '^[a-zA-Z0-9_]+$')MYSQL_PASSWORD(regex: '[a-zA-Z0-9_~!@#$%&*()-=<>,.?;:|]+$')MYSQL_DATABASE(regex: '^[a-zA-Z0-9_]+$') ...output omitted...
Add the missing environment variables to the quotesdb deployment.
[student@workstation ~]$oc set env deployment/quotesdb \MYSQL_USER=operator1 MYSQL_PASSWORD=redhat123 MYSQL_DATABASE=quotesdeployment.apps/quotesdb updated
Update the MySQL container image for the quotesdb deployment.
Retrieve the name of the container that is running inside the pod. You need the container name to update its image.
[student@workstation ~]$oc get deployment/quotesdb -o wideNAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS ... quotesdb 1/1 1 1 59mmysql-80...
Set the image to registry.ocp4.example.com:8443/rhel9/mysql-80:1-237.
[student@workstation ~]$oc set image deployment/quotesdb \mysql-80=registry.ocp4.example.com:8443/rhel9/mysql-80:1-237deployment.apps/quotesdb image updated
Verify your work.
[student@workstation ~]$oc get deployment/quotesdb -o wideNAME ... CONTAINERS IMAGES quotesdb ... mysql-80registry.ocp4.example.com:8443/rhel9/mysql-80:1-237
Wait for the deployment to roll out.
You might have to rerun the command several times for the pod to report a Running status.
The name of the pod on your system probably differs.
[student@workstation ~]$oc get podsNAME READY STATUS RESTARTS AGE frontend-5fb85b4c75-5s7xr 0/1 CrashLoopBackOff 15 (3m39s ago) 56mquotesdb-54d64749c4-chhq61/1Running0 106s
Add a readiness and a liveness probe to the quotesdb deployment that runs the mysqladmin ping command.
Use the oc set probe command with the --readiness option to add the readiness probe.
[student@workstation ~]$oc set probe deployment/quotesdb \--readiness -- mysqladmin pingdeployment.apps/quotesdb probes updated
Use the oc set probe command with the --liveness option to add the liveness probe.
[student@workstation ~]$oc set probe deployment/quotesdb \--liveness -- mysqladmin pingdeployment.apps/quotesdb probes updated
Define resource limits for the quotesdb deployment.
Set the CPU request to 200 millicores and the memory request to 256 MiB.
Set the CPU limit to 500 millicores and the memory limit to 1 GiB.
[student@workstation ~]$oc set resources deployment/quotesdb \--requests cpu=200m,memory=256Mi --limits cpu=500m,memory=1Gideployment.apps/quotesdb resource requirements updated
Add a readiness and a liveness probe to the frontend deployment.
Use the oc set probe command with the --readiness option to add the readiness probe that tests the /status path on HTTP port 8000.
[student@workstation ~]$oc set probe deployment/frontend --readiness \--get-url http://:8000/statusdeployment.apps/frontend probes updated
Use the oc set probe command with the --liveness option to add the liveness probe that tests the /env path on HTTP port 8000.
[student@workstation ~]$oc set probe deployment/frontend --liveness \--get-url http://:8000/envdeployment.apps/frontend probes updated
Define resource limits for the frontend deployment.
Set the CPU request to 200 millicores and the memory request to 256 MiB.
Set the CPU limit to 500 millicores and the memory limit to 512 MiB.
[student@workstation ~]$oc set resources deployment/frontend \--requests cpu=200m,memory=256Mi --limits cpu=500m,memory=512Mideployment.apps/frontend resource requirements updated
Scale the frontend deployment to three pods.
Scale the deployment.
[student@workstation ~]$ oc scale deployment/frontend --replicas 3
deployment.apps/frontend scaledWait for the deployment to scale up.
You might have to rerun the command several times for the pods to report a Running status.
The names of the pods on your system probably differ.
[student@workstation ~]$oc get podsNAME READY STATUS RESTARTS AGEfrontend-86cdd7c7bf-8vrrs1/1Running0 3m10sfrontend-86cdd7c7bf-ds79w1/1Running0 44sfrontend-86cdd7c7bf-hpnwz1/1Running0 44s quotesdb-66ff98b88c-fhwhs 1/1 Running 0 12m
Verify that the application responds to web requests.
Retrieve the URL of the application.
[student@workstation ~]$oc get routeNAME HOST/PORT PATH SERVICES ... frontendfrontend-compreview-scale.apps.ocp4.example.comfrontend ...
Use the curl command to test the application.
[student@workstation ~]$curl \http://frontend-compreview-scale.apps.ocp4.example.com<html> <head> <title>Quotes</title> </head> <body> <h1>Quote List</h1> <ul> <li>1: When words fail, music speaks. - William Shakespeare </li> ...output omitted...