All Products
Search
Document Center

Container Compute Service:Canary release by traffic splitting in Knative

Last Updated:Oct 23, 2026

Knative manages traffic distribution between different revisions. You can set the traffic percentage for each revision in the console and gradually shift traffic to a new revision while monitoring its performance. The canary release is complete when the new revision handles 100% of the traffic.

Prerequisites

You have deployed Knative in the ACS cluster.

Step 1: Create a Knative service

  1. Log on to the ACS console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Applications > Knative.

  3. On the Knative page, on the Services tab, select default from the Namespace drop-down list, and then click Create Service. On the configuration page, deploy a service named helloworld-go and click Create.

    The following table describes the key parameters. For more information about the parameters, see Quickly deploy a Knative service.

    Parameter

    Description

    Namespace

    Select the namespace to which the service belongs.

    Service Name

    Enter a name for the service. This example uses helloworld-go.

    Image Name

    You can click Select Image. In the dialog box that appears, select the desired image and click OK. You can also enter the path of an image from a private registry. The format is domainname/namespace/imagename:tag. In this example, the path is registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go.

    Access Protocol

    Supports HTTP and gRPC access protocols.

    Note

    gRPC, built on the efficient HTTP/2 standard, uses the Protocol Buffers (Protobuf) serialization protocol and supports many programming languages.

    Container Port

    The container port to expose. The port number must be between 1 and 65535.

    If the Status column of the target service displays Created, the service has been successfully deployed.

  4. On the Services page, obtain the domain name and gateway address from the Default Domain and Gateway columns for the helloworld-go Service, respectively.

  5. Run the following command to access the helloworld-go Service.

    curl -H "Host: <default_domain>" http://<gateway_ip> # Replace <default_domain> and <gateway_ip> with your actual values.

    Expected output:

    Hello World!

    The expected output indicates that the Service is created and accessible.

Step 2: Perform a canary release

  1. Log on to the ACS console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Applications > Knative.

  3. Create a Revision.

    1. Click the Services tab. In the Actions column on the right side of the target Service, click Details.

    2. Click Create Revision. In the Basic Information step of the configuration wizard, click Advanced, set the environment variable of the new Revision to TARGET=Knative, and then click Next.

      11

    3. In the Traffic Splitting Settings step of the configuration wizard, set the Percent of the new Revision to 0, and then click Create.

      Note

      The sum of the traffic percentages of all Revisions must be 100.

    4. After the Revision is created, click the Services tab to view the details of the newly created Revision.

    5. Run the following command to access the helloworld-go Service.

      curl -H "Host: <default_domain>" http://<gateway_ip> # Replace <default_domain> and <gateway_ip> with your actual values.

      Expected output:

      Hello World!

      The expected output indicates that the Service is created and accessible. Because the Percent of the new Revision is 0, requests to the helloworld-go Service are still routed to the old Revision.

  4. Modify the traffic percentages to perform the canary release.

    1. On the Services page, in the Actions column on the right side of the target Service, click Details.

    2. Click Set Traffic Percentage. In the Split Traffic dialog box, set the Percent of both the new Revision and the old Revision to 50%, and then click OK.

    3. After the Percent is set for the Service, click the Services tab to view the details of the new and old Revisions.

    4. Run the following command to access the Service.

      while true; do curl -H "Host: <default_domain>" http://<gateway_ip>; sleep 1; done # Replace <default_domain> and <gateway_ip> with your actual values.
      Note

      This command runs continuously until you manually stop it. If you want to observe the output for only a while, press Ctrl + C to stop the command.

      Expected output:

      Hello World!
      Hello Knative!
      Hello World!
      Hello Knative!
      Hello World!
      Hello Knative!
      ...

      Because the Percent of the new Revision and the old Revision is set to 50%, requests to the helloworld-go Service are currently split approximately evenly between the two Revisions.

      You can continue the canary release of the Service by adjusting the Percent until the Percent of the new Revision reaches 100%, which completes the canary release. If you find issues with the new Revision during this process, you can perform a rollback at any time by adjusting the Percent.

Related topics

You can configure auto scaling for your Knative service based on the number of concurrent requests. For more information, see Configure request-based auto scaling for a service.