Lab: Openshift S2I and Templates
Last updated
Last updated
S2I is a tool deployed in OpenShift that provides a repeatable method to generate application images from source/binary code. Templates provide a parameterized set of objects that can be processed by OpenShift.
In this lab you'll use these capabilities to deploy a small legacy Java EE app to OpenShift in a multi-user OpenShift environment
1.1 Login into the OpenShift web console using the user credentials provided to you
Access the OpenShift console via the url link provided by the workshop instructors
Select clouddragons-ldap
login option
Login with the username and password provided by the workshop instructors
1.2 From the OpenShift web console click on your username in the upper right and select Copy Login Command
1.3 You are prompted to login to the OpenShift console again. Repeat the same login procedure above to login.
1.4 Click Display Token link.
1.5 Copy the contents in the field Log in with this token. It provides a valid login command with an alive token.
1.6 Paste the login command in a terminal window and run it (Note: leave the web console browser tab open as you'll need it later on in the lab)
1.7 If prompted with Use insecure connections? (y/n):
, enter y.
1.8 Set an environment variable for your studentid based on your user identifier from the instructor (e.g. user001)
1.9 Create a new OpenShift project for this lab
2.1 Clone the the WebSphere Liberty S2I image source by issuing the following commands in the terminal window you just used to login via the CLI
2.2 Get the hostname of your OpenShift internal registry so you can push images to it
2.3 Create a new OpenShift project for this lab (Note: your project name must be unique. Combine your lab STUDENT ID with the prefix pbw-
to create a unique project name like pbw-user???
where user???
is your username e.g. user012
)
2.4 Build the S2I Liberty image and tag it appropriately for the internal registry
2.5 Login to the internal registry
2.6 Push the S2I Liberty image to the internal registry
3.1 In your Web console browser tab select the Developer role at the top left and make sure your project (ie pbw-user???) is selected.
3.2 Click on the Database tile
3.4 Click on MariaDB (Ephemeral)
3.5 Click Instantiate Template
3.6 Enter the following values for the fields indicated below (leave remaining values at their default values)
When you're done the dialog should look like the following:
3.7 Click Create
3.8 Wait until the Status changes to Ready before continuing
4.1 From your terminal go back to your home directory
4.2 From the client terminal window clone the Git repo with the following commands
5.1 Add the Plants by WebSphere Liberty app template to your OpenShift cluster
5.2 In your Web console browser click on + Add (top left)
5.3 Click the From Catalog tile
5.4 Select the Other category and then click on the Plants by WebSphere on Liberty tile
5.5 Click Instantiate Template
5.6 Click Create
5.7 To see the progress of the build and subsequent deployment select the Administrator role, then select Workloads and then Pods. The builder pod should be running (Note: that name of the pod will have build as a suffix)
5.8 After a few minutes the build pod will terminate and the pod with the Plants by Websphere app will appear. Wait for that pod to show Ready before continuing. (Note: the name of the pod will not have build as a suffix).
5.9 In the navigation area on the left click Networking and then Routes. Click on the link in the Location column to launch the Plants By WebSphere app.
6.1 From the Plants by WebSphere app UI, click on the HELP link
6.2. Click on Reset database to populate the MariaDB database with data
6.3. Verify that browsing different sections of the online catalog shows product descriptions and images.
With even small simple apps requiring multiple OpenShift objects, templates greatly simplify the process of distributing OpenShift apps. S2I allows you to reuse the same builder image for apps on the same app server, avoiding the effort of having to create unique images for each app.
Field name
Value
MariaDB Connection Username
pbwadmin
MariaDB Connection Password
l1bertyR0cks
MariaDB Database Name
plantsdb