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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: node-blue namespace: f5demo spec: replicas: 1 template: metadata: labels: run: node-blue spec: containers: - image: "chen23/f5-demo-app:openshift" env: - name: F5DEMO_APP value: "website" - name: F5DEMO_NODENAME value: "Node Blue (No SSL)" - name: F5DEMO_NODENAME_SSL value: "Node Blue (SSL)" - name: F5DEMO_COLOR value: "0000FF" - name: F5DEMO_COLOR_SSL value: "0000FF" imagePullPolicy: IfNotPresent name: node-blue ports: - containerPort: 80 - containerPort: 443 protocol: TCP --- apiVersion: v1 kind: Service metadata: name: node-blue labels: run: node-blue namespace: f5demo spec: ports: - port: 8080 protocol: TCP targetPort: 8080 name: http - port: 8443 protocol: TCP targetPort: 8443 name: https type: ClusterIP selector: run: node-blue --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: node-green namespace: f5demo spec: replicas: 1 template: metadata: labels: run: node-green spec: containers: - image: "chen23/f5-demo-app:openshift" env: - name: F5DEMO_APP value: "website" - name: F5DEMO_NODENAME value: "Node Green (No SSL)" - name: F5DEMO_COLOR value: "99FF99" - name: F5DEMO_NODENAME_SSL value: "Node Green (SSL)" - name: F5DEMO_COLOR_SSL value: "00FF00" imagePullPolicy: IfNotPresent name: node-green ports: - containerPort: 80 - containerPort: 443 protocol: TCP --- apiVersion: v1 kind: Service metadata: name: node-green labels: run: node-green spec: ports: - port: 8080 protocol: TCP targetPort: 8080 name: http type: ClusterIP selector: 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
apiVersion: v1 kind: Route metadata: labels: name: f5-demo-app-bg-route name: f5-demo-app-bg-route namespace: f5demo annotations: # Specify a supported BIG-IP load balancing mode virtual-server.f5.com/balance: least-connections-node virtual-server.f5.com/health: | [ { "path": "mysite-bg.f5demo.com/", "send": "HTTP GET /", "interval": 5, "timeout": 10 } ] spec: host: mysite-bg.f5demo.com port: targetPort: 8080 to: kind: Service name: node-blue weight: 20 alternateBackends: - kind: Service name: node-green 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