Lab: Run Applications as Containers and Pods
Run a web server as a pod and insert a debug page that displays diagnostic information.
Outcomes
Deploy a pod from a container image.
Retrieve the status and events of a pod.
Troubleshoot a failed pod.
Edit pod resources.
Copy files to a running pod for diagnostic purposes.
Use port forwarding to connect to a running pod.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that exercise resources are available.
[student@workstation ~]$ lab start pods-review
Procedure 3.4. Instructions
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.
Log in to the OpenShift cluster as the developer user with the developer password.
Use the pods-review project for your work.
Log in to the OpenShift cluster and change to the
pods-reviewproject.Deploy a pod named
webphpthat uses theregistry.ocp4.example.com:8443/redhattraining/webphp:v1container image. Determine why the pod fails to start.Troubleshoot the failed
webphppod by creating a debug pod.The application developer resolved the identified issue in the
registry.ocp4.example.com:8443/redhattraining/webphp:v2container image. In a terminal window, edit thewebphppod resource to use thev2image tag. Retrieve the status of thewebphppod. Then, confirm that the user in the container is an unprivileged user and belongs to therootgroup. Confirm that therootgroup permissions are correct for the/run/httpddirectory.Connect port
8080on theWorkstationmachine to port8080on thewebphppod. In a new terminal window, retrieve the content of the pod's127.0.0.1:8080/index.phpweb page to confirm that the pod is operational.NOTE
The terminal window that you connect to the
webphppod must remain open for the remainder of the lab. This connection is necessary for the final lab step and for thelab gradecommand.An issue occurs with the PHP application that is running on the
webphppod. To debug the issue, the application developer requires diagnostic and configuration information for the PHP instance that is running on thewebphppod.The
~/DO180/labs/pods-reviewdirectory contains aphpinfo.phpfile to generate debugging information for a PHP instance. Copy thephpinfo.phpfile to the/var/www/html/directory on thewebphppod.Then, confirm that the PHP debugging information is displayed when accessing the
127.0.0.1:8080/phpinfo.phpfrom a web browser.
Evaluation
As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.
[student@workstation ~]$ lab grade pods-review
Finish
As the student user on the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.
[student@workstation ~]$ lab finish pods-review

