F5 Solutions for Containers > Appendix > Appendix 4: Advanced OpenShift Topics > Module 2: Container Connector in Action Source | Edit on
Lab 2.3 - Route - Blue/Green Testing¶
The F5 Container Connector supports Blue/Green application testing e.g testing two different versions of the same application, by using the weight parameter of OpenShift Routes. The weight parameter allows you to establish relative ratios between application Blue and application Green. So, for example, if the first route specifies a weight of 20 and the second a weight of 10, the application associated with the first route will get twice the number of requests as the application associated with the second route.
Just as in the previous exercise, the F5 Container Connector reads the Route resource and creates a virtual server, node(s), a pool per route path and pool members.
However, in order to support Blue/Green testing using OpenShift Routes, the Container Connector creates an iRule and a datagroup on the BIG-IP. The iRule handles the connection routing based on the assigned weights.
Note
At smaller request volumes, the ratio of requests to the Blue application and the requests to the Green application may not match the relative weights assigned in the OpenShift Route. However, as the number of requests increases, the ratio of requests between the Blue application and the Green application should closely match the weights assigned in the OpenShift Route.
Deploy version 1 and version 2 of demo application and their associated Services
From ose-master1, review the following deployment: f5-demo-app-bg-deployment.yaml
1apiVersion: extensions/v1beta1 2kind: Deployment 3metadata: 4 name: node-blue 5 namespace: f5demo 6spec: 7 replicas: 1 8 template: 9 metadata: 10 labels: 11 run: node-blue 12 spec: 13 containers: 14 - image: "chen23/f5-demo-app:openshift" 15 env: 16 - name: F5DEMO_APP 17 value: "website" 18 - name: F5DEMO_NODENAME 19 value: "Node Blue (No SSL)" 20 - name: F5DEMO_NODENAME_SSL 21 value: "Node Blue (SSL)" 22 - name: F5DEMO_COLOR 23 value: "0000FF" 24 - name: F5DEMO_COLOR_SSL 25 value: "0000FF" 26 imagePullPolicy: IfNotPresent 27 name: node-blue 28 ports: 29 - containerPort: 80 30 - containerPort: 443 31 protocol: TCP 32 33--- 34 35apiVersion: v1 36kind: Service 37metadata: 38 name: node-blue 39 labels: 40 run: node-blue 41 namespace: f5demo 42spec: 43 ports: 44 - port: 8080 45 protocol: TCP 46 targetPort: 8080 47 name: http 48 - port: 8443 49 protocol: TCP 50 targetPort: 8443 51 name: https 52 type: ClusterIP 53 selector: 54 run: node-blue 55 56--- 57 58apiVersion: extensions/v1beta1 59kind: Deployment 60metadata: 61 name: node-green 62 namespace: f5demo 63spec: 64 replicas: 1 65 template: 66 metadata: 67 labels: 68 run: node-green 69 spec: 70 containers: 71 - image: "chen23/f5-demo-app:openshift" 72 env: 73 - name: F5DEMO_APP 74 value: "website" 75 - name: F5DEMO_NODENAME 76 value: "Node Green (No SSL)" 77 - name: F5DEMO_COLOR 78 value: "99FF99" 79 - name: F5DEMO_NODENAME_SSL 80 value: "Node Green (SSL)" 81 - name: F5DEMO_COLOR_SSL 82 value: "00FF00" 83 imagePullPolicy: IfNotPresent 84 name: node-green 85 ports: 86 - containerPort: 80 87 - containerPort: 443 88 protocol: TCP 89 90--- 91 92apiVersion: v1 93kind: Service 94metadata: 95 name: node-green 96 labels: 97 run: node-green 98spec: 99 ports: 100 - port: 8080 101 protocol: TCP 102 targetPort: 8080 103 name: http 104 type: ClusterIP 105 selector: 106 run: node-green
Now that you have reviewed the Deployment, you need to actually create it by deploying it to OpenShift by using the oc create command:
oc create -f f5-demo-app-bg-deployment.yaml -n f5demo
Create OpenShift Route for Blue/Green Testing
The basic Route example from the previous exercise only included one path. In order to support Blue/Green application testing, a Route must be created that has two paths. In OpenShift, the second (and subsequent) path is defined in the alternateBackends section of a Route resource.
From ose-master1, review the following Route: f5-demo-app-bg-route.yaml
1apiVersion: v1 2kind: Route 3metadata: 4 labels: 5 name: f5-demo-app-bg-route 6 name: f5-demo-app-bg-route 7 namespace: f5demo 8 annotations: 9 # Specify a supported BIG-IP load balancing mode 10 virtual-server.f5.com/balance: least-connections-node 11 virtual-server.f5.com/health: | 12 [ 13 { 14 "path": "mysite-bg.f5demo.com/", 15 "send": "HTTP GET /", 16 "interval": 5, 17 "timeout": 10 18 } 19 ] 20spec: 21 host: mysite-bg.f5demo.com 22 port: 23 targetPort: 8080 24 to: 25 kind: Service 26 name: node-blue 27 weight: 20 28 alternateBackends: 29 - kind: Service 30 name: node-green 31 weight: 10
Note
How the Route resource refers to two different services: The first service is for the Blue application with a weight of 20 and the second service is for the Green application with a weight of 10.
Attention
Knowledge Check: How many requests will the **Blue* application receive relative to the Green application?*
Now that you have reviewed the Route, you need to actually create it by deploying it to OpenShift by using the oc create command:
oc create -f f5-demo-app-bg-route.yaml
Verify that the Route was successfully creating by using the OpenShift oc get route command. Note that, under the SERVICES column, the two applications are listed along with their request distribution percentages.
oc get route -n f5demo
Attention
Knowledge Check: What would the Route percentages be if the weights were 10 and 40?
Review BIG-IP configuration. Examine the BIG-IP configuration for changes made by the Container Connector after the the OpenShift Route was deployed.
Using the Chrome web browser, navigate to
and change the partition to ocp using the dropdown in the upper right.Note
There are two pools defined: one pool for the Blue application and a second pool for the Green application. Additionally, the Container Connector also creates an iRule and a datagroup that the BIG-IP uses to distribute traffic based on the weights assigned in the OpenShift Route.
Test the application. Use the Chrome browser to access blue and green applications you previously deployed.
Because the Route resource you created specifies a hostname for the path, you will need to use a hostname instead of an IP address to access the demo application. Open a new browser tab and enter the hostname http://mysite-bg.f5demo.com in to the address bar
Refresh the browser periodically and you should see the web page change from the Blue application to the Green application and back to the Blue application as noted by the colors on the page.
Generate some request traffic. Use the Linux curl utility to send a large volume of requests to the application.
As the number of requests increases, the relative number of requests between the Blue application and the Green application begins to approach the weights that have been defined in the OpenShift Route.
From the ose-master1 server, run the following command to make 1000 requests to the application:
for i in {1..1000}; do curl -s -o /dev/null http://mysite-bg.f5demo.com; done
Review the BIG-IP configuration
In the previous step, you used the curl utility to generate a large volume of requests. In this step, you will review the BIG-IP pool statistics to see how the requests were distributed between the Blue application and the Green application.
Using the Chrome web browser, navigate to
and change the partition to ocp using the dropdown in the upper right.Cleanup deployed resources. Remove the Deployment, Service and Route resources you created in the previous steps using the OpenShift oc delete command.
From ose-master1 server, run the following commands:
oc delete -f f5-demo-app-bg-route.yaml -n f5demo oc delete -f f5-demo-app-bg-deployment.yaml -n f5demo