Canary Release

On the back of Istio, KubeSphere provides users with necessary control to deploy canary services. In a canary release, you introduce a new version of a service and test it by sending a small percentage of traffic to it. At the same time, the old version is responsible for handling the rest of the traffic. If everything goes well, you can gradually increase the traffic sent to the new version, while simultaneously phasing out the old version. In the case of any occurring issues, KubeSphere allows you to roll back to the previous version as you change the traffic percentage.

This method serves as an efficient way to test performance and reliability of a service. It can help detect potential problems in the actual environment while not affecting the overall system stability.

canary-release-0

Prerequisites

Create Canary Release Job

  1. Log in KubeSphere as project-regular. Under Categories, click Create Job on the right of Canary Release.

    create-canary-release

  2. Set a name for it and click Next.

    set-task-name

  3. Select your app from the drop-down list and the service for which you want to implement the canary release. If you also use the sample app Bookinfo, select reviews and click Next.

    cabary-release-3

  4. On the Grayscale Release Version page, add another version of it (e.g v2) as shown in the image below and click Next:

    canary-release-4

    备注

    The image version is v2 in the screenshot.

  5. You send traffic to these two versions (v1 and v2) either by a specific percentage or by the request content such as Http Header, Cookie and URI. Select Forward by traffic ratio and drag the icon in the middle to change the percentage of traffic sent to these two versions respectively (e.g. set 50% for either one). When you finish, click Create.

    canary-release-5

  6. The canary release job created displays under the tab Job Status. Click it to view details.

    canary-release-job

  7. Wait for a while and you can see half of the traffic go to each of them:

    canary-release-6

  8. The new Deployment is created as well.

    deployment-list-1

  9. You can directly get the virtual service to identify the weight by executing the following command:

    1. kubectl -n demo-project get virtualservice -o yaml

    备注

    • When you execute the command above, replace demo-project with your own project (i.e. namespace) name.
    • If you want to execute the command from the web kubectl on the KubeSphere console, you need to use the account admin.
  10. Expected output:

    1. ...
    2. spec:
    3. hosts:
    4. - reviews
    5. http:
    6. - route:
    7. - destination:
    8. host: reviews
    9. port:
    10. number: 9080
    11. subset: v1
    12. weight: 50
    13. - destination:
    14. host: reviews
    15. port:
    16. number: 9080
    17. subset: v2
    18. weight: 50
    19. ...

Take a Job Offline

  1. After you implement the canary release, and the result meets your expectation, you can select Take Over from the menu, sending all the traffic to the new version.

    take-over-traffic

  2. To remove the old version with the new version handling all the traffic, click Job offline.

    job-offline