In this lab we introduce how to simplify your container deployments with OpenShift templates. We will also explore the web console.
This lab should be performed on YOUR ASSIGNED AWS VM as ec2-user
unless otherwise instructed.
Expected completion: 20 minutes
Let's create a new project.
$ oc new-project production
Now using project "production" on server "https://10.xx.xx.xxx:8443".
Ensure you're still logged in as the developer user.
$ oc whoami
developer
This time, let's simplify things by deploying an application template. We've already included a template with lab5 which leverages our wordpress & mariadb images.
$ cd ~/rh-container-lab/labs/lab5/
$ grep localhost:5000 wordpress-template.yaml
Feel free to view the full template.
Let's deploy this wordpress template by adding your template to the production project
$ oc create -f wordpress-template.yaml
template "wordpress" created
Deploy your new template with "oc new-app" and note its output
$ oc new-app --template wordpress
--> Deploying template "production/wordpress" to project production
View all of the newly created resources
$ oc get all
Wait for rollout to finish
$ oc rollout status -w dc/mariadb
replication controller "mariadb-1" successfully rolled out
$ oc rollout status -w dc/wordpress
replication controller "wordpress-1" successfully rolled out
Verify the database started
$ oc logs dc/mariadb
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Verify wordpress started
$ oc logs dc/wordpress
/usr/sbin/httpd -D FOREGROUND
oc status
gives a nice view of how these resources connect
$ oc status
Check and make sure you can access the wordpress service through it's route:
$ oc get routes
$ curl -L wordpress-production.<YOUR AWS VM PUBLIC IP>.nip.io
- Or open the URL in a browser to view the UI
OpenShift includes several ready-made templates. Let's take a look at some of them:
$ oc get templates -n openshift
For more information on templates, reference the official OpenShift documentation:
https://docs.openshift.com/container-platform/latest/dev_guide/templates.html
Now that we have deployed our template, let’s login as developer to the OpenShift web console - https://<YOUR AWS VM PUBLIC DNS NAME HERE>:8443
The console url can be retrieved with:
$ oc cluster status
Login to the web console with the developer
user.
And after we’ve logged in, we see a list of projects that the developer user has access to. Let's select the production
project:
Our project landing page provides us with a high-level overview of our wordpress application's pods, services, and route. Notice the wordpress deployment shows 2 pods due to our template's replica setting:
Let's dive a little deeper. We want to view a list of our pods by clicking on Pods
in the left Applications menu:
Next, let's click on one of our running pods for greater detail:
With this view, we have access to pod information like status, logs, image, volumes, and more:
Feel free to continue exploring the console.
In the final bonus lab you'll get to play with some new features, the service catalog and broker.