In this lab, we will use an OpenShift Template to replicate the product-catalog application deployment, using the next-release imagestream tag. We will then review the ability of OpenShift Routes to split application network traffic across multiple OpenShift/K8S Services, enabling either A-B Test or Blue/Green Release Deployments.
In this step, we will use a YAML Template to generate a product-catalog Test deployment in our OpenShift project:
-
From the command line and where this project was cloned, navigate to the /lab/.openshift directory
-
Ensure you are logged into OpenShift and your Lab Project, then execute the following oc command:
oc process -f product-catalog-test-tmp.yaml | oc create -f -
If the command executed successfully, you should see the following output
deploymentconfig "product-catalog-test" created service "product-catalog-test" created route "product-catalog-test" created
-
From the OpenShift Web console, you should now see a new instance of the Product Catalog application deployed as "product-catalog-test". Use the newly created Route to verify the Application, it shares the same Postgres DB as the initial deployment:
In this step, we will update the the product catalog app and before releasing it, use the ability of OpenShift Routes to split traffic across multiple OpenShift K8S Services to implement an A/B Test Deployment:
-
Let’s start by updating the version number in our Product Catalog List. Edit the jsp page - /lab/src/main/resources/META-INF/resources/WEB-INF/jsp/productList.jsp and update the version number in the html page-header as shown below:
<div class="page-header"> <h1>Admin - Product List v1.01</h1> </div>
Remember to commit/push your changes to your repo for before the next step.
-
Kick-off the product-catalog-mvn-pipeline build pipeline, to create and deploy a new container image with our update. Do not execute the Tag and Release step. At this point, we should now have two versions of our Product Catalog application deployed, represented by the latest (new build at version 1.01) and next-release (original build at version 1.00).
-
Go ahead and open both versions of the application in two different Browser tabs, using the product-catalog and product-catalog-test Routes and validate that they each display the different html page header.
-
We will now update the product-catalog-test Route to split traffic across both the product-catalog and product-catalog-test Services. From the Web Console, select Applications, Routes, then the product-catalog-test Route. Select Edit from the Actions Drop-Down list and update the Route as shown below:
The product-catalog-test application deployment should be updated as shown below:
We know have the ability to conduct A/B Test Scenerios using the product-catalog-test Route which will evenly disperse http client sessions across the two application versions we have deployed in our OpenShift project. See this in action, open a Browser tab in your current session for the product-catalog-test Route:
Now open a new Browser window using a private session for the product-catalog-test Route again. It may take a couple of tries of opening new Browser window’s with private sessions, depending on where we are at in the Round-Robin routing, but you should be able to view the other version of the Application:
In this step, we will demonstrate a Blue/Green deployment, using the product-catalog-test application deployment within our OpenShift Project, leveraging the ability to split or direct http network traffic across multiple OpenShift/K8S Services:
-
Now that we have created Product Catalog release 1.01, let’s make that available to the Testing team that is testing against our product-catalog-test Route, by forcing all traffic to use our latest application build. Select Applications, Routes, then the product-catalog-test Route. Edit the Route and update/save the configuration as shown below:
-
To verify that all Browser sessions point to the latest application build, refresh the page used on both Browser windows we use for our A/B Test. They should now both display Admin - Product List v1.01.
-
Consider the following Scenario, the Testing team found an issue with the new release. While the Testing team wants to continue verifying their new automated test suite against the current release, the Dev Team wants to fix/unit test the new features. To keep our Delivery stream moving, let’s update the product-catalog-test Route to fall-back to the current release. Go back like we did previously and update/save the product-catalog-test so 100% of the traffic goes to the product-catalog-test Service. After you save your changes, your Route Configuration should look like this:
Now refresh the page in each Browser session like we did previously, they should both display Admin - Product List v1.00. Now both teams can continue on with their Development and Testing activities without interruption!