×
Community Blog Use ASM to Manage Knative Services (5): Canary Deployment of Services Based on Traffic in Knative on ASM

Use ASM to Manage Knative Services (5): Canary Deployment of Services Based on Traffic in Knative on ASM

Part 5 of this 6-part series describes how to implement canary deployment of services based on traffic in Knative on ASM.

By Xining Wang

Article Series

Use ASM to Manage Knative Services (1): An Overview of Knative on ASM

Use ASM to Manage Knative Services (2): Use Knative on ASM to Deploy Serverless Applications

Use ASM to Manage Knative Services (3): Use Custom Domain in Knative on ASM

Use ASM to Manage Knative Services (4): Use ASM Gateway to Access Knative Services over HTTPS

Use ASM to Manage Knative Services (5): Canary Deployment of Services Based on Traffic in Knative on ASM

Use ASM to Manage Knative Services (6): Auto Scaling Based on the Number of Traffic Requests

Knative on ASM has the traffic-based canary release capability. When you create a Knative service, Knative will automatically create the first revision for the service. When the configuration of the Knative service changes, a new revision of the Knative service will be created. You can modify the distribution ratio of traffic sent to different revisions to implement the canary release feature. This article describes how to release services based on traffic canary in Knative on ASM.

Prerequisites

  • A Knative Service is created using Knative on ASM. Please see Part 2 for specific operations.
  • Use the default domain name example.com. Please see Part 3 if you use another custom domain name.

Create a Revision in the ACK Console

1.  Log on to the ACK console

2.  On the left-side navigation pane of the ACK console, click Clusters

3.  On the Clusters page, find the cluster you want to manage and click its name or click Details in the Action Bar

4.  On the left-side navigation pane, choose Applications > Knative

5.  Create a revision. On the Services tab, select the Service name you want to manage and click Details in the Action Bar

6.  On this page, click Create Revision in the upper-right corner

7.  On the Basic Information configuration wizard step, click Advanced Settings to set the environment variables of the latest revision. The name is TARGET, and the variable value is Knative on ASM.

1

8.  Click Next. In the Traffic Settings configuration wizard step, set the traffic ratio of the latest revision to 0 and click Create.

2

Note: The sum of traffic ratios of all revisions must be 100.

  1. After the revision is created, you can find details about the new version on the Services tab.
  2. Run the following command to access the service:
curl http://helloworld-go.default.example.com

Expected output:

Hello World!

As you can see, the traffic ratio is set to 0 for the latest version. This indicates that all requests to access the helloworld-go service are sent to the earlier version.

Modify the Traffic Ratio to Perform a canary Release for the Service

  1. On the Services page, click Details in the Actions column on the right side of the service you created
  2. Click Set Traffic Ratio
  3. In the Set Traffic Ratio dialog box, set the traffic ratios to 50% for both the earlier and new versions and click OK

3

  1. After you finish setting the traffic ratios, check the details about the old and new versions on the Services tab.
  2. Run the following command to access the service:
for i in `seq 20`; do curl http://helloworld-go.default.example.com; done;

Expected output:

Hello Knative on ASM!
Hello Knative on ASM!
Hello World!
Hello Knative on ASM!
Hello World!
Hello World!
Hello World!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello World!
Hello Knative on ASM!
Hello World!
Hello Knative on ASM!
Hello Knative on ASM!
Hello World!
Hello World!

The traffic ratios are set to 50% for both the earlier and new versions. This means requests to access the helloworld Service are evenly distributed to the earlier and new versions.

  1. You can change the traffic ratio to implement canary releases. The new version is completely released if you set the Percent parameter to 100% for the new version. During the process, you can change the value of the Percent parameter to roll back if issues are found in the new version.
  2. If you access the service again, you can get similar results:
for i in `seq 20`; do curl http://helloworld-go.default.example.com; done;

Expected output:

Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
Hello Knative on ASM!
0 0 0
Share on

Xi Ning Wang(王夕宁)

56 posts | 8 followers

You may also like

Comments

Xi Ning Wang(王夕宁)

56 posts | 8 followers

Related Products