This tutorial is part of the Learning path: Deploying Red Hat OpenShift Container Platform 4.x on IBM Power Systems Virtual Servers.
|Topics in “Exploring Red Hat OpenShift on Power Systems Virtual Server”||Type|
|Deploying Acme Air microservices application on Red Hat OpenShift Container Platform||Tutorial|
|Deploying a sample MongoDB geospatial application on Red Hat OpenShift Container Platform||Tutorial|
|Enable continuous deployment using Red Hat OpenShift S2I and GitHub webhooks||Tutorial|
|Deliver webhooks without worrying about firewalls||Tutorial|
|Installing IBM Cloud Pak for Data 3.5 on Red Hat OpenShift Container Platform 4.6 on IBM Power Systems Virtual Server||Tutorial|
|Deploy Enterprise MongoDB using Helm charts on Red Hat OpenShift for IBM Power Systems||Tutorial|
|Build an application on IBM Power Systems Virtual Server using Tekton pipeline and triggers||Tutorial|
Acme Air is a full-fledged sample application for a fictitious airline called Acme Air which handles flight bookings with thousands of entries in its database. The implementation can support running on a variety of runtime platforms including virtual machines (VMs), Red Hat® OpenShift®, Docker containers, IBM Cloud®, and other Kubernetes environments. This tutorial shows you how to deploy the application on Red Hat OpenShift Container Platform on IBM Power Systems™ and to build your own images and perform updates on a running deployment.
The project consists of five components as shown in Figure 1. The front-end and deployment scripts are in the Main Service project.
Figure 1. Major components of Acme Air
You need to make sure that the following prerequisites are fulfilled before deploying the sample Acme Air application.
- A running OpenShift Container Platform 4.x cluster must be set up on an IBM Power Systems server
- A Re Hat Quay.io account
Note: Quay.io is a container registry that contains the images for the Acme Air application.
The approximate time to deploy the sample Acme Air application and make updates to the images is around 30 minutes.
Deploy the application
Perform the following steps to deploy the application on OpenShift on an IBM Power Systems server.
Clone the https://github.com/ocp-power-demos/acmeair-mainservice-java repository and run the deployToOpenshift.sh script. The script does not require any input parameters.
The GitHub repositories for acme air in the ocp-power-demos organization are a fork of https://github.com/blueperf
git clone https://github.com/ocp-power-demos/acmeair-mainservice-java cd acmeair-mainservice-java ./scripts/deployToOpenshift.sh
After successful completion, the output as shown in Figure 2 is displayed.
Figure 2. The namespace and URL information are provided at the end of the deployment
Run the following command to check the status of the pods. Notice that the pods are in the Running state.
$ oc get pods NAME READY STATUS RESTARTS AGE acmeair-authservice-58459f88c9-bdmt6 1/1 Running 0 2m50s acmeair-booking-db-66d696dfd4-5lw7k 1/1 Running 0 2m50s acmeair-bookingservice-7fdd8789c4-6h28l 1/1 Running 0 2m50s acmeair-customer-db-6f4d998ffb-qfb9w 1/1 Running 0 2m50s acmeair-customerservice-fffd899d5-27jb7 1/1 Running 0 2m50s acmeair-flight-db-54684fb648-sdvsl 1/1 Running 0 2m50s acmeair-flightservice-5566cc7d79-vnqgx 1/1 Running 0 2m50s acmeair-mainservice-7f846794d5-5nmk4 1/1 Running 0 2m50s
To access the application, open the URL provided in the output of the script in a browser. Click the Configure the Acme Air environment link to load the database and start using the application.
Figure 3. Acme Air homepage for Version 1.0
Build your own images for Acme Air
Each repository for Acme Air is present in https://github.com/ocp-power-demos organization. You can make updates to the application across the five components and can deploy seamlessly without uninstalling the application.
Code updates and image creation
To demonstrate, we will make a version change to the front end of the application dashboard. After an update is performed, the change will be reflected on the browser without having to uninstall the application.
Fork the https://github.com/ocp-power-demos repository to your GitHub account to start creating changes. Create a new branch on the acmeair-mainservice-java repository. Because this is a version update, we call this branch version-update.
git clone https://github.com/<fork-repository-account>/acmeair-mainservice-java cd acmeair-mainservice-java git checkout -b version-update
Update the code in the Java™ web application.
As a small update, change the version of the application from Version 1.0 to Version 1.1. Update the HTML code under acmeair-mainservice-java/src/main/webapp/.
Note: There is a separate HTML file for each page of the application under the webapp directory.
Figure 4. Header section of the HTML file contains the title image and caption of the Acme Air web application
Update the deployment YAML file (deploy-acmeair-mainservice-java.yaml) in the manifests-openshift directory of the source code to reflect the version of the new image for future deployments. Update the quay.io username with the account registered to you. The tag used here is 1.1 to relate to our new version 1.1.
Figure 5. An example of the image name in the deploy-acmeair-mainservice-java.yaml deployment manifest
As the images will be built using Travis CI, you need to authorize Travis CI to push images to our Quay.io account. To do this, create a new robot account in Quay.io and add the credentials to Travis CI. To create a new robot account, go to the Robot Account section in your Quay.io account and add a name and description and click Create robot account.
Figure 6. Creating a robot account
Notice that the credentials for the robot account are provided in the Robot Token section. The username and token can be shared by multiple repositories that are owned by a user or organization.
Figure 7. Token generated after creating a new robot account
Create a new empty public repository in Quay.io with the name of the image. To create a repository in the Quay.io UI, click the + (plus) icon at the upper-right side of the header on any Quay.io page and click New Repository.
Figure 8. Selecting the option to create a new repository
Figure 9. Window to create a new repository
Select the newly created repository (in this example, acmeair-mainservice-java) under REPOSITORY NAME and click Settings.
Figure 10. Selecting the new repository
In the User and Robot Permissions section, add the robot token with Write permissions.
Figure 11. User and Robot permissions on the Repository settings page
Go to travis-ci.org, navigate to your Travis CI account settings and enable the project under the Repositories section. Repositories in travis-ci.org are disabled by default.
Figure 12. The repositories section in user account settings
To populate the environment variables in travis-ci.org, click Settings next to the project name. Add two environment variables, ROBOT_TOKEN and ROBOT_USER and set the values from step 5. The names of the environment variables should match the variable names given in the .travis.yml file.
Figure 13. Environment variables for robot user and token
Update the .travis.yml file in the repository source code.
IMAGE_PREFIXmust contain the name of your Quay.io repository and the ACME_VERSION is the image tag, which is 1.1.
The .travis.yml file specifies the tasks for Travis CI to perform. The robot user and token information will be picked up directly from the environment variables set in the travis-ci.org repository settings.
Figure 14. Acme Air build configuration in the .travis.yml file
Push the local changes to remote. After successfully pushing the code, the Travis CI job will begin, and a new version of the image will be generated in Quay.io.
Figure 15. Green check mark indicating that the job is successful
Perform a rolling update
Each deployment for Acme Air has a rolling update strategy. You may update fields for
RollingUpdate during deployment with the required values.
StrategyType: RollingUpdate MinReadySeconds: 0 RollingUpdateStrategy: 25% max unavailable, 25% max surge
Run the following command to perform the rolling update:
$ oc set image deployments/acmeair-mainservice acmeair-mainservice-java=quay.io/<quay.io account>/acmeair-mainservice-java:1.1 --record deployment.apps/acmeair-mainservice image updated
Track the status of the rolling update.
$ oc rollout status deployment acmeair-mainservice deployment "acmeair-mainservice" successfully rolled out
Open the Acme Air URL provided in Figure 2 in a browser. Note that the version has changed to 1.1.
Figure 16. Acme Air home page with the updated version 1.1
Notice that a new pod for
mainserviceis created for the newly updated deployment. The new image will also be reflected in the deployment.
$ oc get pods NAME READY STATUS RESTARTS AGE acmeair-authservice-58459f88c9-qdxjd 1/1 Running 0 18h acmeair-booking-db-66d696dfd4-ngb4x 1/1 Running 0 18h acmeair-bookingservice-7fdd8789c4-wh52r 1/1 Running 0 18h acmeair-customer-db-6f4d998ffb-2grwv 1/1 Running 0 18h acmeair-customerservice-fffd899d5-s95dj 1/1 Running 0 18h acmeair-flight-db-54684fb648-mn6zk 1/1 Running 0 18h acmeair-flightservice-5566cc7d79-gjnrv 1/1 Running 0 18h acmeair-mainservice-657594bdb4-hgtgf 1/1 Running 0 64m
You can perform similar steps to build images for all the five projects as required. Making updates and deploying this sample application can help you to discover and understand the different features of OpenShift on IBM Power Systems servers. You can also perform performance benchmark tests, change the update strategy, and add in your own set of features to the application.