Lab: Deploy Managed and Networked Applications on Kubernetes
Deploy a database server and a web application that connects to that database and expose the web application to external access.
Outcomes
Deploy a MySQL database from a container image.
Deploy a web application from a container image.
Configure environment variables for a deployment.
Expose the web application for external access.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that the cluster is accessible and that all exercise resources are available. It also creates the database-applications project.
[student@workstation ~]$ lab start deploy-review
Procedure 4.5. 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 database-applications project for your work.
Log in to the OpenShift cluster and change to the
database-applicationsproject.Create a MySQL database deployment named
mysql-appby using theregistry.ocp4.example.com:8443/redhattraining/mysql-app:v1image, and identify the root cause of the failure.Configure the environment variables for the
mysql-appdeployment by using the following information:| Field | Value | | --- | --- | |
MYSQL_USER|redhat| |MYSQL_PASSWORD|redhat123| |MYSQL_DATABASE|world_x|Then, execute the following command in the
mysql-appdeployment pod to load theworld_xdatabase:/bin/bash -c "mysql -uredhat -predhat123 </tmp/world_x.sql"Create a service for the
mysql-appdeployment by using the following information:| Field | Value | | --- | --- | | Name |
mysql-service| | Port |3306| | Target port |3306|Create a web application deployment named
php-appby using theregistry.ocp4.example.com:8443/redhattraining/php-webapp:v1image.Create a service for the
php-appdeployment by using the following information:| Field | Value | | --- | --- | | Name |
php-svc| | Port |8080| | Target port |8080|Then, create a route named
phpappto expose the web application to external access.Test the connectivity between the web application and the MySQL database. In a web browser, navigate to the
phpapp-web-app.apps.ocp4.example.comroute, and verify that the application retrieves data from the MySQL database.
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 deploy-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 deploy-review
