You can forward requests to different TKE backends based on the request/system parameter values, such as the Host or UserName in the request header. This is suitable for various scenarios, including grayscale release, blue-green deployment, and tenant routing. The TKE backend upstream can be combined with the conditional routing plugin to implement data distribution.
For the usage and features of conditional routing, see Conditional Routing Plugin.
Create an API on the API Gateway service page. Select VPC resources as the backend type of the API and select TKE upstream as the upstream.
After the API is published, create a conditional routing plugin.
Select Plugin > System Plugin on the left sidebar in the console.
Click Create and select Conditional routing as the type.
Create a conditional routing policy: the semantics of the conditional routing in the following example is that when the value of UserName in the request header is admin
, the request will be forwarded to the TKE upstream upstream-1ca1d6yi
.
Policy details:
ServiceType: HTTP
ServiceConfig:
Method: ANY
Path: /
Url: 'http://127.0.0.1/'
UniqVpcId: vpc-s0g8gpo5
UpstreamId: upstream-1ca1d6yi
Product: upstream
The conditional routing plugin is bound to the API created in step 1.
If the request matches the conditional routing policy (header with UserName as admin
), it will be forwarded to upstream-1ca1d6yi
; otherwise, the default backend configured for the API will be used.
Conditional routing can match not only request headers but also clientIp. For more capabilities of conditional routing, see Conditional Routing Plugin.
Was this page helpful?