All Products
Search
Document Center

Container Compute Service:Perform a canary release for a service based on traffic splitting in Knative

Last Updated:Mar 26, 2026

Knative distributes traffic across revisions using configurable percentages. By gradually shifting traffic from an old revision to a new one — and monitoring service behavior at each step — you can validate new releases safely and roll back instantly if issues appear.

Prerequisites

Before you begin, ensure that you have:

  • Knative deployed in your ACS cluster. For more information, see Deploy Knative.

Step 1: Create a Knative service

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

  2. On the Clusters page, find the cluster you want to manage and click its ID. In the left-side navigation pane of the cluster details page, choose Applications > Knative.

  3. On the Knative page, go to the Services tab. Set Namespace to default and click Create Service. On the configuration page, create a service named helloworld-go and click Create. The following table describes the key parameters. For a full parameter reference, see Use Knative to deploy serverless applications. When the Status column shows Created, the service is deployed.

    Parameter Description
    Namespace The namespace the service belongs to.
    Service Name A name for the service. This example uses helloworld-go.
    Image Name Click Select images, select an image, and click OK. To use a private registry, enter the image address in domainname/namespace/imagename:tag format. This example uses registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go.
    Access Protocol HTTP or gRPC. gRPC is built on the HTTP/2 standard and the Protocol Buffers (Protobuf) serialization protocol, and offers more compact and efficient data transfer than HTTP.
    Container Port The container port to expose. Valid values: 1 to 65535.
  4. On the Services tab, click the helloworld-go service and record the domain name from the Default Domain field and the gateway IP address from the Gateway field.

  5. Run the following command to verify the service is accessible:

    curl -H "Host: <default_domain_name>" http://<gateway_IP_address>

    Expected output:

    Hello World!

Step 2: Create a revision and deploy a canary release

Create a revision

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

  2. On the Clusters page, find the cluster you want to manage and click its ID. In the left-side navigation pane of the cluster details page, choose Applications > Knative.

  3. On the Services tab, select the helloworld-go service and click Details in the Actions column.

  4. Click Create Revision. On the Basic Information wizard page, click Advanced, set the environment variable to TARGET=Knative, and click Next.

    11

  5. On the Traffic Splitting Settings wizard page, set Percent % to 0 for the new revision and click Create. Setting the new revision to 0% keeps all production traffic on the old revision while the new revision is deployed and available. This lets you test the new revision independently before shifting any traffic.

    The traffic percentages across all revisions must add up to 100.
  6. After the revision is created, run the following command to confirm all traffic still goes to the old revision:

    curl -H "Host: <default_domain_name>" http://<gateway_IP_address>

    Expected output:

    Hello World!

Split traffic to start the canary release

  1. On the Services tab, select the helloworld-go service and click Details in the Actions column.

  2. Click Split Traffic. In the Split Traffic dialog box, set Percent % to 50% for both the old and new revisions, then click OK.

  3. Run the following command to verify that traffic is split evenly between the two revisions:

    This command runs until you stop it. Press Ctrl + C to terminate.
    while true; do curl -H "Host: <default_domain_name>" http://<gateway_IP_address>; sleep 1; done

    Expected output:

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

    Requests alternate between the old revision (Hello World!) and the new revision (Hello Knative!), confirming the 50/50 split.

Complete or roll back the release

Once you verify the new revision is stable, complete the release or roll back as needed:

  • Complete the release: Click Split Traffic and set Percent % to 100% for the new revision. This routes all traffic to the new revision.

  • Roll back: If issues appear at any point, click Split Traffic and set Percent % to 100% for the old revision to immediately revert all traffic.

What's next

Configure auto scaling for your Knative service to handle traffic spikes automatically. For more information, see Configure auto scaling based on the number of requests.