# 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.

```plaintext
[student@workstation ~]$ lab start pods-review
```

**Procedure 3.4. Instructions**

The API URL of your OpenShift cluster is [https://api.ocp4.example.com:6443](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.

1. Log in to the OpenShift cluster and change to the `pods-review` project.
    
    [Show Solution](https://rol.redhat.com/rol/app/#)
    
2. Deploy a pod named `webphp` that uses the [`registry.ocp4.example.com:8443/redhattraining/webphp:v1`](http://registry.ocp4.example.com:8443/redhattraining/webphp:v1) container image. Determine why the pod fails to start.
    
    [Show Solution](https://rol.redhat.com/rol/app/#)
    
3. Troubleshoot the failed `webphp` pod by creating a debug pod.
    
    [Show Solution](https://rol.redhat.com/rol/app/#)
    
4. The application developer resolved the identified issue in the [`registry.ocp4.example.com:8443/redhattraining/webphp:v2`](http://registry.ocp4.example.com:8443/redhattraining/webphp:v2) container image. In a terminal window, edit the `webphp` pod resource to use the `v2` image tag. Retrieve the status of the `webphp` pod. Then, confirm that the user in the container is an unprivileged user and belongs to the `root` group. Confirm that the `root` group permissions are correct for the `/run/httpd` directory.
    
    [Show Solution](https://rol.redhat.com/rol/app/#)
    
5. Connect port `8080` on the `Workstation` machine to port `8080` on the `webphp` pod. In a new terminal window, retrieve the content of the pod's `127.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 the `lab grade` command.
    
    [Show Solution](https://rol.redhat.com/rol/app/#)
    
6. 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 the `webphp` pod.
    
    The `~/DO180/labs/pods-review` directory contains a `phpinfo.php` file to generate debugging information for a PHP instance. Copy the `phpinfo.php` file to the `/var/www/html/` directory on the `webphp` pod.
    
    Then, confirm that the PHP debugging information is displayed when accessing the `127.0.0.1:8080/phpinfo.php` from a web browser.
    
    2. ![](https://rol.redhat.com/rol/static/static_file_cache/do180-4.12/pods/review/assets/php-debug-console.png align="center")
        
    
    [Show Solution](https://rol.redhat.com/rol/app/#)
    

**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.

```plaintext
[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.

```plaintext
[student@workstation ~]$ lab finish pods-review
```
