All Products
Search
Document Center

Container Service for Kubernetes:Canary release for a Knative Service

Last Updated:Oct 14, 2026

Knative manages traffic distribution between Revisions. You can set the traffic percentage of each Revision in the console and adjust the percentages while monitoring the Service until 100% of the service traffic is shifted to the new Revision, which completes the canary release.

Prerequisites

Knative is deployed in your cluster. For more information, see Deploy and manage Knative components.

Step 1: Create a Knative Service

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

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

  3. On the Knative page, click the Services tab, set Namespace to default, and then click Create Service. Configure a Service named helloworld-go and click Create.

    The following table describes the key parameters. For more information about the other parameters, see Step 1: Deploy a Knative service.

    Parameter

    Description

    Service Name

    A custom name for the Service. In this example, the Service is named helloworld-go.

    Image Name

    Click Select Image. In the dialog box that appears, select the image and version that you want to use, and then click OK.

    You can also enter a private registry. Use the domainname/namespace/imagename:tag format. In this example, use registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:73fbdd56.

    Access Protocol

    The HTTP and gRPC access protocols are supported.

    Note

    gRPC is built on the HTTP/2 protocol standard and the Protocol Buffers (protobuf) serialization protocol, and supports many programming languages. Compared with HTTP, HTTP/2 is more compact and efficient for sending and receiving data.

    Container Port

    The container port to expose. The port number must be an integer from 1 to 65535.

    If the Status column of the target Service displays Created, the Service is 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 by creating a Revision

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

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click 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.

References

You can configure autoscaling for a Knative Service based on the number of requests. For more information, see Enable auto scaling to withstand traffic fluctuations.