You can use traffic lanes in permissive mode to achieve application version isolation. By designating an E2E pass-through request header as the request routing header, you can use the header's value to route traffic to swimlanes. When services within a swimlane call each other, if a destination service does not exist in the current swimlane, the request is forwarded to the baseline lane. This ensures call chain integrity and simplifies traffic management.
Before you begin, ensure you have read and understood Use permissive mode traffic lanes to manage end-to-end traffic and its related content.
Scenario overview
This example uses three services, mocka, mockb, and mockc, to create three swimlanes (s1, s2, and s3) that represent three versions of a service call chain. The s1 swimlane is the baseline lane and contains all three services. The s2 swimlane contains only the mocka and mockc services. The s3 swimlane contains only the mockb service. In this scenario, both the E2E pass-through request header and the request routing header are set to my-trace-id.
Step 1: Create a swimlane group and swimlanes
-
Create a swimlane group.
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
-
On the Traffic Lane page, click Create Swimlane Group. In the Create Swimlane Group panel, configure the parameters and click OK.
Parameter
Description
Name of swim lane group
In this example, set the name to test.
Entrance gateway
Select ingressgateway.
Lane Mode
Select Permissive Mode.
Pass-through Mode of Trace Context
Select Pass Through Custom Header.
E2E Pass-through Request Header
Set this to
my-trace-id.Swimlane service
Select the target Kubernetes cluster and the default
namespace. In the list of services, select mocka, mockb, and mockc. Click the
icon to move them to the selected area.
-
-
Create the
s1,s2, ands3swimlanesand bind them to thev1,v2, andv3versions, respectively.-
In the Traffic Lane section of the Traffic Rule Definition page, click Create swimlanes.
-
In the Create swimlanes dialog box, configure the parameters and click OK.
Parameter
Description
Swimlane Name
Set the names of the three
swimlanesto s1, s2, and s3, respectively.Configure Service Tag
Label Key: Set to ASM_TRAFFIC_TAG.
Label Value: Set to v1, v2, and v3 for the
s1,s2, ands3swimlanes, respectively.Add Service
For the
s1swimlane: Select mocka(default), mockb(default), and mockc(default).For the
s2swimlane: Select mocka(default) and mockc(default).For the
s3swimlane: Select mockb(default).After the three
swimlanesare created, the result is displayed. By default, the firstswimlaneyou create in a group becomes thebaseline lane. You can change thebaseline lane. When traffic is sent to a service that does not exist in anotherswimlane, thefallback mechanismforwards the request to thebaseline lane. For more information about how to change the baseline lane, see Modify the baseline lane. On the Traffic Rule Definition page, the Baseline Lane is set to s1, and the Ingress Type is ASM Gateway (ingressgateway).After you create the three
swimlanes, Alibaba Cloud Service Mesh automatically generates aDestinationRuleand aVirtualServicefor each service in theswimlanegroup. You can view them by choosing or Virtual Service in the navigation pane on the left. For example, ASM automatically creates the followingDestinationRuleandVirtualServicefor themockaservice.
-
-
Create
traffic routing rulesfor the threeswimlanes.-
In the Traffic Lane section of the Traffic Rule Definition page, find the target
swimlaneand click Ingress traffic rules in the Actions column. -
In the Add drainage rule dialog box, configure the parameters and click OK.
This example assumes that the ingress API for all
swimlaneservices is/mock. Therefore, you configure the sametraffic routing rulefor eachswimlane.Parameter
Description
Ingress service
Select mocka.default.svc.cluster.local.
Ingress traffic rules
For the
traffic routing rulesof the threeswimlanes, set the Name to r1, r2, and r3, respectively. Set the realm name to *.Matching request URI
Set Method to Exact and Content to /mock.
After you create the
traffic routing rulesfor the threeswimlanes, the result is displayed. In addition to the exact URI match, each rule includes a Headers match condition: the header name ismy-trace-id, the match type is exact, and the match values for thes1,s2, ands3swimlanesares1,s2, ands3, respectively. The Baseline Lane is set to s1.After you create the rules, ASM automatically generates a
VirtualServicethat defines thetraffic routing rulefor eachswimlane. For example, ASM generates the followingVirtualServicefor thes2swimlane.
-
Step 2: Verify E2E canary release
-
Obtain the public IP address of the ASM
ingress gateway. For more information, see Obtain the IP address of an ingress gateway. -
Run the following command to set an environment variable.
In the command,
xxx.xxx.xxx.xxxis the IP address that you obtained in the previous step.export ASM_GATEWAY_IP=xxx.xxx.xxx.xxx -
Verify the
E2E canary release.-
Run the following command to test access to the
s1swimlane.The
my-trace-idvalue,s1, is the name of thes1swimlaneconfigured in Step 1.2.for i in {1..100}; do curl -H'my-trace-id: s1' http://${ASM_GATEWAY_IP}/mock ; echo ''; sleep 1; done;Expected output:
-> mocka(version: v1, ip: 172.17.0.54)-> mockb(version: v1, ip: 172.17.0.129)-> mockc(version: v1, ip: 172.17.0.130)The output confirms that requests with the HTTP header
my-trace-id: s1route to the services in thes1swimlane. -
Run the following command to test access to the
s2swimlane.The
my-trace-idvalue,s2, is the name of thes2swimlaneconfigured in Step 1.2.for i in {1..100}; do curl -H'my-trace-id: s2' http://${ASM_GATEWAY_IP}/mock ; echo ''; sleep 1; done;Expected output:
mocka(version: v2, ip: 192.168.1.101)-> mockb(version: v1, ip: 192.168.1.100)-> mockc(version: v2, ip: 192.168.1.116)The output shows that requests with the HTTP header
my-trace-id: s2route to services in thes2swimlane. When a request targets themockbservice, which does not exist in thes2swimlane, thefallback mechanismforwards the request to themockbservice in thes1baseline lane. Subsequent requests to themockcservice correctly route back to themockcservice in thes2swimlane. -
Run the following command to test access to the
s3swimlane.The
my-trace-idvalue,s3, is the name of thes3swimlaneconfigured in Step 1.2.for i in {1..100}; do curl -H'my-trace-id: s3' http://${ASM_GATEWAY_IP}/mock ; echo ''; sleep 1; done;Expected output:
mocka(version: v1, ip: 192.168.1.103)-> mockb(version: v3, ip: 192.168.1.120)-> mockc(version: v1, ip: 192.168.1.105)The output shows that requests with the HTTP header
my-trace-id: s3route to the service in thes3swimlane. When requests target themockaandmockcservices, which do not exist in thes3swimlane, thefallback mechanismforwards the requests to themockaandmockcservices in thes1baseline lane.
-