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-review
project.Deploy a pod named
webphp
that uses theregistry.ocp4.example.com:8443/redhattraining/webphp:v1
container image. Determine why the pod fails to start.Troubleshoot the failed
webphp
pod by creating a debug pod.The application developer resolved the identified issue in the
registry.ocp4.example.com:8443/redhattraining/webphp:v2
container image. In a terminal window, edit thewebphp
pod resource to use thev2
image tag. Retrieve the status of thewebphp
pod. Then, confirm that the user in the container is an unprivileged user and belongs to theroot
group. Confirm that theroot
group permissions are correct for the/run/httpd
directory.Connect port
8080
on theWorkstation
machine to port8080
on thewebphp
pod. In a new terminal window, retrieve the content of the pod's127.0.0.1:8080/index.php
web page to confirm that the pod is operational.NOTE
The terminal window that you connect to the
webphp
pod must remain open for the remainder of the lab. This connection is necessary for the final lab step and for thelab grade
command.An issue occurs with the PHP application that is running on the
webphp
pod. To debug the issue, the application developer requires diagnostic and configuration information for the PHP instance that is running on thewebphp
pod.The
~/DO180/labs/pods-review
directory contains aphpinfo.php
file to generate debugging information for a PHP instance. Copy thephpinfo.php
file to the/var/www/html/
directory on thewebphp
pod.Then, confirm that the PHP debugging information is displayed when accessing the
127.0.0.1:8080/phpinfo.php
from 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