Canary Deployment Strategy¶
A canary deployment consists of routing a subset of traffic from the old version to the new version of the application based on weight to reduce the risk of deploying a new version that impacts the workload. For example, 90 percent of the traffic goes to the old version, and 10 percent goes to the new version.
This deployment involves making small staged releases and sending them to a small subset of users for testing and observation. Once no bugs are encountered and canary deployment works well, users can easily revert to a new version and delete the old version of the application.
Use the following steps to upgrade the SPK Application Pods to a newer version using the Canary deployment.
Install the SPK TCPTestApp with version 0.11.0 using Helm
helm install spk-tcp --namespace=xyz-app --version=0.11.0 f5ing-testapp-v1 f5-ingress-dev/f5ing-testapp --set service.port=8051 --set service.protocol=TCP --set app.port=8051 --set service.targetPort=8050 --set ingress.enabled=false --set app.destinationAddress=10.33.0.55 --set app.persist.mode="PERSIST_TYPE_NONE" --set app.persist.timeout=300 --set app.persist.hashAlg="PERSIST_HASH_DEFAULT" --set app.serviceDownAction="POOLMBR_ACTION_REJECT"
Important: The SPK Controller watches this app namespace and pushes it to TMM’s load balancing pool member list.
Note: Once the SPK TCPTestApp is installed, automatically the deployment with version 0.11.0 and the pod under it get created. And also, the ClusterIP service is created.
Verify the STATUS of the SPK TCPTestApp Pod with version 0.11.0:
oc get pod -n xyz-app
NAME READY STATUS RESTARTS AGE f5ing-testapp-v1-84d985cd-jvn7 1/1 Running 0 8s
Obtain the IP address of the SPK TCPTestApp Pod:
In this example, SPK TCPTestApp Pod is installed in the xyz-app Project.
oc get svc -n xyz-app
In this example, SPK TCPTestApp CLUSTER-IP address is 172.30.234.85 and the PORT(S) is 8051.
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE f5ing-testapp-v1 ClusterIP 172.30.234.85 <none> 8051/TCP 22s
Scale the SPK TCPTestApp Pod to 2 more in the deployment_v1:
oc scale --replicas=3 deployment f5ing-testapp-v1 -n xyz-app
Verify the total pods created in deployment_v1:
oc get pod -n xyz-app
NAME READY STATUS RESTARTS AGE f5ing-testapp-v1-84d985-dc4cq 0/1 Running 0 3s f5ing-testapp-v1-84d985-hvvr8 1/1 Running 0 18s f5ing-testapp-v1-84d985-srcws 1/1 Running 0 18s
Verify the deployment_v1 status:
oc get deploy -n xyz-app
NAME READY UP-TO-DATE AVAILABLE AGE f5ing-test-app-v1 3/3 3 3 30s
Create a deployment of version 0.11.4 named deployment_v2.yaml with 1 pod using the download the file here.
oc create -f deployment_v2.yaml
Important: Ensure that the labels in the deployment of version 0.11.4 match those in the deployment of version 0.11.0 so that the pod is created as one more endpoint on the same service.
Verify the details of the deployments created:
oc get deploy -n xyz
NAME READY UP-TO-DATE AVAILABLE AGE f5ing-testapp-v1 3/3 3 3 2m f5ing-testapp-v2 1/1 1 1 20s
Note: Please notice that two deployments are displayed under one service since the labels are the same.
Verify the total pods created in both the deployments:
oc get pod -n xyz-app -o wide
In this example, 3 pods of version 0.11.0 and 1 pod of version 0.11.4 are created.
NAME READY STATUS RESTARTS AGE IP NODE f5ing-testapp-v1-84d985cd-7nplz 1/1 Running 0 4h29m 10.128.2.148 worker-0.ocp3.pd.f5net.com f5ing-testapp-v1-84d985cd-gddd9 1/1 Running 0 4h29m 10.128.2.147 worker-0.ocp3.pd.f5net.com f5ing-testapp-v1-84d985cd-szc4s 1/1 Running 0 4h29m 10.131.0.201 worker-1.ocp3.pd.f5net.com f5ing-testapp-v2-7f69d59fd-nn2vw 1/1 Running 0 4h26m 10.128.2.149 worker-0.ocp3.pd.f5net.com
Verify the traffic is flowing to all the pods:
nc -v 10.33.0.55 8051
In this example, the app pod with IP 10.128.2.147 responded:
Connection to 10.33.0.55 8051 port [tcp/*] succeeded! Hello echo from TCP server [10.128.2.147]: Hello
In this example, the app pod with IP 10.128.2.148 responded:
Connection to 10.33.0.55 8051 port [tcp/*] succeeded! Hi echo from TCP server [10.128.2.148]: Hi
In this example, the app pod with IP 10.131.0.201 responded:
Connection to 10.33.0.55 8051 port [tcp/*] succeeded! Good Morning echo from TCP server [10.131.0.201]: Good Morning
In this example, the app pod with IP 10.128.2.149 responded
Connection to 10.33.0.55 8051 port [tcp/*] succeeded! Good Evening echo from TCP server [10.128.2.149]: Good Evening
In this way, traffic will be distributed accordingly.