All Products
Search
Document Center

Container Service for Kubernetes:Canary release for a Knative service

Last Updated:Sep 18, 2026

Knative lets you split traffic between revisions. You can set the traffic percentage for each revision in the console and then gradually adjust the percentages while monitoring the service. A canary release is complete when 100% of the traffic is routed to the new revision.

Prerequisites

Before you begin, ensure that you have:

Knative deployed in your cluster. For more information, see Quick start: Deploy a Knative Service.

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 Services tab of the Knative page, select default from the Namespace drop-down list, and then click Create Service. Configure a service named helloworld-go and then click Create.

    The following table describes the key parameters. For details about other parameters, see Deploy a Knative service.

    Parameter

    Description

    Service Name

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

    Image Name

    Click Select Image. In the dialog box that appears, select the desired image and version and click OK.

    You can also specify 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

    Supports the HTTP and gRPC access protocols.

    Note

    gRPC uses the HTTP/2 protocol and the Protocol Buffers (protobuf) serialization protocol, and supports a wide range of programming languages. Compared with HTTP, HTTP/2 is more compact and efficient for sending and receiving data.

    Container Port

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

    If Created is displayed in the Status column, the service is deployed.

  4. On the Services page, obtain the domain and gateway address of the helloworld-go service from the Default Domain and Gateway columns, 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 output indicates that the service is running and accessible.

Step 2: Create a revision for canary release

  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. Find the target service and click Details in the Actions column.

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

      11

    3. In the Traffic Splitting Settings step, set the Percent for the new revision to 0 and click Create.

      Note

      The sum of traffic percentages for all revisions must be 100.

    4. After the revision is created, click the Services tab to view the details of the new service 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 output indicates that the service is running and accessible. Because the Percent for the new revision is 0, requests to the helloworld-go service still go to the old revision.

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

    1. On the Services page, find the target service and click Details in the Actions column.

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

    3. After the Percent is set, 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 stop it. To stop the command, press Ctrl+C.

      Expected output:

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

      Because the Percent for the new and old revisions is 50% each, Knative splits requests to the helloworld-go service approximately evenly between the two revisions.

      You can continue the canary release of the service by adjusting the Percent until the Percent for the new version reaches 100% to complete the release. During this process, if you find any issues with the new version, you can roll back at any time by adjusting the Percent.

Related documents

You can configure autoscaling for a Knative service based on the number of requests. For more information, see Autoscale a service based on the number of requests.