All Products
Search
Document Center

Container Service for Kubernetes:Perform a canary release based on traffic splitting for a Knative Service

Last Updated:Mar 26, 2026

When you release a new version of a Knative service, routing all traffic at once risks exposing users to potential bugs. Knative lets you split traffic across multiple revisions by percentage, so you can validate a new revision with a small slice of production traffic before fully rolling it out—or roll back immediately if issues appear.

Prerequisites

Before you begin, ensure that you have:

How it works

A canary release with Knative Serving follows three stages:

Stage Action Description
Deploy Create a new revision Deploy a new version of your Knative service as a revision with 0% of traffic, so it's live but not yet serving requests.
Validate Shift traffic incrementally Move a percentage of traffic (for example, 50%) to the new revision and verify it behaves correctly.
Complete or roll back Set traffic to 100% or revert Fully release the new revision by routing all traffic to it, or roll back by returning all traffic to the previous revision.

Step 1: Create a Knative service

  1. Log on to the ACK console. In the left navigation pane, click ACK consoleClusters.

  2. On the Clusters page, find the cluster you want and click its name. In the left navigation pane, choose Applications > Knative.

  3. On the Services tab of the Knative page, set Namespace to default. Click Create Service to deploy a service named helloworld-go. After configuring the service, click Create. The following table describes the key parameters. For more details, see Deploy a Knative Service. When the Status column shows Created, the service is deployed.

    Parameter Description
    Service Name Enter a name for the service. This example uses helloworld-go.
    Image Name Click Select Image to choose an image and tag, then click OK. You can also enter a private registry address in domainname/namespace/imagename:tag format. This example uses registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56.
    Access Protocol Supports HTTP and gRPC. gRPC is based on the HTTP/2 standard and Protocol Buffers (protobuf) serialization, and supports multiple programming languages.
    Container Port The container port to expose. Valid values: 1 to 65535.
  4. On the Services tab, click the helloworld-go service and record its domain name and gateway IP address from the Default Domain and Gateway fields.

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

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

    Replace <default_domain_name> and <gateway_IP_address> with the actual values. Expected output:

    Hello World!

Step 2: Create a revision and deploy a canary release

Create a revision

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

  2. On the Clusters page, find the cluster you want and click its name. In the left navigation pane, 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 page, click Advanced, set the environment variable to TARGET=Knative, and click Next.

    Create revision - advanced settings

  5. On the Traffic Splitting Settings page, set the traffic Percent % for the latest revision to 0 and click Create.

    Note

    The traffic percentages across all revisions must sum 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!

    The output shows Hello World! because the new revision has a traffic percentage of 0%, so all requests are still routed to the old revision.

Shift traffic to the new revision

  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 the traffic Percent % to 50 for both the old and the new revision, then click OK.

  3. Run the following loop command to observe live traffic distribution:

    Note

    The command runs indefinitely. Press Ctrl + C to stop it.

    while true; do curl -H "Host: <default_domain_name>" http://<gateway_IP_address>; sleep 1; done

    Expected output at a 50/50 split:

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

    Requests to helloworld-go are evenly distributed between the old and new revisions.

  4. Continue adjusting the traffic percentage based on your validation results. To change the split, click Split Traffic on the Services tab and update the percentage values. Set Percent % to 100 for the new revision to fully release it.

Roll back to the previous revision

If you discover issues in the new revision, roll back by routing all traffic to the old revision.

  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 the Percent % to 100 for the old revision and 0 for the new revision, then click OK. All requests are now routed to the old revision. Verify the rollback by running the curl command—the output should show only Hello World!.

What's next

Configure auto scaling for a Knative service based on request volume. For more information, see Enable auto scaling to withstand traffic fluctuations.