All Products
Search
Document Center

Microservices Engine:Configure a canary release

Last Updated:Jan 12, 2024

If you want to update a Spring Cloud or Dubbo application that is deployed on an Elastic Compute Service (ECS) instance or in a Container Service for Kubernetes cluster, you can perform a canary release for the application to test the stability of the new version to be released. An application of the new version is deployed on some servers. A canary release helps you test the canary version of the application based on a small percentage of traffic. After the canary version is proven to be stable, you can update the application on all servers. This topic describes how to configure a canary release to update a Spring Cloud application that is deployed in an Container Service for Kubernetes cluster.

Prerequisites

The Microservices Governance component of Microservices Engine (MSE) is installed in an ACK cluster, and Microservices Governance is enabled for applications in the ACK cluster. For more information, see Connect microservice applications that are deployed in an ACK cluster to Microservices Governance.

Limits

The canary release feature is suitable only for scenarios in which you want to update a single application. We recommend that you implement an end-to-end canary release in other update scenarios. For more information, see Implement an end-to-end canary release by using MSE cloud-native gateways.

Procedure

The following figure shows the process of a canary release.

金丝雀发布流程

Initial status

In this example, two applications are used: Order-Service and Pay-Service. Order-Service is used as a service consumer to call the services that are provided by Pay-Service. Before you enable Microservices Governance for Order-Service and Pay-Service, Order-Service and Pay-Service correspond to two separate deployments that are not tagged.

Deploy a canary version

Create a deployment that represents the canary version of Pay-Service and add a tag to the deployment.

Note

By default, Microservices Governance of MSE routes all traffic to the untagged deployment.

Configure a traffic rule

Configure the following expression for the Header parameter as a traffic rule for Pay-Service: env = test. In this case, the traffic that meets the rule is routed to the canary deployment, and other traffic is routed to the untagged deployment.

Adjust the traffic percentage

Increase the percentage of traffic that is sent to the canary deployment.

Important

After the traffic percentage is adjusted, the traffic that meets the rule is still routed to the canary deployment. The traffic that does not meet the rule is routed to the canary deployment at a probability of 20%.

Complete the canary release

If the canary version is proven to be stable, use the stable version to update the image and click Complete. Then, all traffic is routed to the deployment of the stable version.

Note

We recommend that you change the number of replicas for the canary deployment to 0 after the canary release is complete. This way, you do not need to repeatedly create deployments.

Procedure

This topic describes how to configure traffic rules when you perform a canary release. Follow the instructions that are displayed on the Canary Release tab in the MSE console to complete other steps.

  1. Log on to the MSE console, and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Governance > Application Governance.

  3. On the Application list page, click the resource card of the destination application. In the left-side navigation pane, click Traffic management.

  4. Follow the instructions that are provided on the Canary tab to complete the canary release.

    金丝雀发布.png

    1. Perform a check.

    2. Create a canary deployment.

    3. Introduce traffic. Click Introduce traffic in Step 3 of the instructions or Click Introduce traffic on the Canary tab. Click OK.

      Important
      • If you want to test the canary version only by using the traffic percentage, you can configure the traffic percentage on the Canary Release by Ratio tab.

      • If fine-grained testing is required, you can configure both traffic rules and content rules on the Canary Release by Ratio and Canary Release by Content tabs.

      Parameters on the Canary Release by Ratio tab

      Parameter

      Description

      Tag

      Displays the tags of the deployments.

      Link Delivery

      Displays whether the deployments support end-to-end pass-through.

      Instances/Percentage

      Displays the number of deployments and the current traffic percentages of the deployments.

      Traffic Percentage

      Specifies the traffic percentages that you want to use for the canary release.

      Operated At

      Displays the last operation time of the deployments.

      Important

      After the canary deployment is proven to be stable based on the traffic rule, increase the traffic percentage of the canary deployment. We recommend that you gradually increase the traffic percentage of the canary deployment.

      Parameters on the Canary Release by Content tab

      Parameter

      Description

      Framework Type

      The framework type is automatically selected based on the application for which you want to perform a canary release.

      Path

      Select a service path. You can also click Switch to Manual Input on the right to enter a path.

      Condition Mode

      Select Meet All Conditions or Meet One of Conditions based on your business requirements.

      Conditions

      Configure condition parameters. If you want to configure multiple conditions, you can click Add Rule Condition to add conditions.

      You can configure four types of condition parameters: Cookie, Header, Parameter, and Body Content. Examples:

      • Cookie: hello = "world" or hello = "world2"

      • Parameter: name = newversion

      Link Delivery

      Turn on this switch if you want to perform end-to-end traffic throttling. For more information, see Configure tag-based routing.

    After you configure the traffic rule, if an access request contains the parameters that are specified in the rule, the request is routed to the canary deployment.

  5. (Optional) If you want to update the traffic rule during the canary release, click Introduce traffic to update the traffic rule, and click OK.

Result

The canary version is proven to be stable

Click Complete. The traffic percentage of the untagged deployment is changed to 100%, and the configured traffic rule is disabled. In this case, all traffic is routed to the untagged deployment.

Note

We recommend that you change the number of replicas for the canary deployment to 0 after the canary release is complete. This way, you do not need to repeatedly create deployments.

The canary version is proven to be unstable

Click Rollback. The traffic percentage of the canary deployment is changed to 0%, and the configured traffic rule is deleted. In this case, all traffic is routed to the untagged deployment. You can then remove the canary deployment.