Merge pull request #3104 from steverao/2.2.x-docs

docs: polish governance user document.
pull/3105/head^2
RuanSheng 2 years ago committed by GitHub
commit b71902a0d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -97,7 +97,7 @@ public class ConsumerApplication {
Rule routeRule = new HeaderRoutingRule();
routeRule.setCondition("=");
routeRule.setKey("tag");
routeRule.setValue("gray");
routeRule.setValue("v2");
Rule routeRule1 = new UrlRoutingRule.ParameterRoutingRule();
routeRule1.setCondition(">");
routeRule1.setKey("id");
@ -139,7 +139,7 @@ public class ConsumerApplication {
Rule routeRule = new HeaderRoutingRule();
routeRule.setCondition("=");
routeRule.setKey("tag");
routeRule.setValue("gray");
routeRule.setValue("v2");
Rule routeRule1 = new UrlRoutingRule.ParameterRoutingRule();
routeRule1.setCondition(">");
routeRule1.setKey("id");

@ -56,7 +56,7 @@ public void getDataFromControlPlaneTest() {
routeRule.setType("header");
routeRule.setCondition("=");
routeRule.setKey("tag");
routeRule.setValue("gray");
routeRule.setValue("v2");
RouteRule routeRule1 = new UrlRule.Parameter();
routeRule1.setType("parameter");
routeRule1.setCondition(">");
@ -82,7 +82,7 @@ public void getDataFromControlPlaneTest() {
}
```
代码对应的规则如下:
若同时满足请求参数中含有`tag=gray`请求头中含有id且值小于10uri为`/router-test`则流量全部路由到v2版本中若有一条不满足则流量路由到v1版本中。
若同时满足请求参数中含有`tag=v2`请求头中含有id且值小于10uri为`/router-test`则流量全部路由到v2版本中若有一条不满足则流量路由到v1版本中。
规则也支持动态修改,测试动态修改的规则如下:
```java
@ -99,7 +99,7 @@ public void getDataFromControlPlaneTest() {
routeRule.setType("header");
routeRule.setCondition("=");
routeRule.setKey("tag");
routeRule.setValue("gray");
routeRule.setValue("v2");
RouteRule routeRule1 = new UrlRule.Parameter();
routeRule1.setType("parameter");
routeRule1.setCondition(">");
@ -127,7 +127,7 @@ public void getDataFromControlPlaneTest() {
}
```
代码对应的规则如下:
若同时满足请求参数中含有`tag=gray`请求头中含有id且值小于10uri为`/router-test`则50%流量路由到v2版本中剩下的流量路由到v1版本中若有一条不满足则流量路由到v1版本中。
若同时满足请求参数中含有`tag=v2`请求头中含有id且值小于10uri为`/router-test`则50%流量路由到v2版本中剩下的流量路由到v1版本中若有一条不满足则流量路由到v1版本中。
##### 演示步骤
1. 访问 http://localhost:18083/add 将路由规则由控制面接口推入路由规则仓库中。
@ -135,7 +135,7 @@ public void getDataFromControlPlaneTest() {
```
Route in 30.221.132.228: 18081,version is v1.
```
访问 http://localhost:18083/router-test?id=11 且请求头设置tag值为gray 满足路由规则路由到v2版本中v2版本实例打印返回如下结果
访问 http://localhost:18083/router-test?id=11 且请求头设置tag值为v2 满足路由规则路由到v2版本中v2版本实例打印返回如下结果
```
Route in 30.221.132.228: 18082,version is v2.
```
@ -145,7 +145,7 @@ public void getDataFromControlPlaneTest() {
```
Route in 30.221.132.228: 18081,version is v1.
```
访问 http://localhost:18083/router-test?id=11 且请求头设置tag值为gray 满足路由规则50%路由到v2版本中v2版本实例打印返回如下结果
访问 http://localhost:18083/router-test?id=11 且请求头设置tag值为v2 满足路由规则50%路由到v2版本中v2版本实例打印返回如下结果
```
Route in 30.221.132.228: 18082,version is v2.
```
@ -251,7 +251,7 @@ spec:
- match:
- headers:
tag:
exact: gray
exact: v2
uri:
exact: /istio-label-routing
route:
@ -264,19 +264,19 @@ spec:
subset: v1
EOF
```
这条VirtualService指定了一条最简单的标签路由规则将请求头tag为gray,请求路径为`/istio-label-routing`的HTTP请求路由到v2版本其余的流量都路由到v1版本:
这条VirtualService指定了一条最简单的标签路由规则将请求头tag为v2,请求路径为`/istio-label-routing`的HTTP请求路由到v2版本其余的流量都路由到v1版本:
### 效果演示
发送一条不带请求头的HTTP请求至IstioConsumerApplication:
```
curl --location --request GET '127.0.0.1:18084/istio-label-routing'
```
因为请求头不为gray所以请求将会被路由到v1版本返回如下:
因为请求头不为v2所以请求将会被路由到v1版本返回如下:
```
Route in 30.221.132.228: 18081,version is v1.
```
之后发送一条请求头tag为gray,且请求路径为`/istio-label-routing`的HTTP请求:
之后发送一条请求头tag为v2,且请求路径为`/istio-label-routing`的HTTP请求:
```
curl --location --request GET '127.0.0.1:18084/istio-label-routing' --header 'tag: gray'
curl --location --request GET '127.0.0.1:18084/istio-label-routing' --header 'tag: v2'
```
因为满足路由规则所以请求会被路由至v2版本:
```
@ -351,11 +351,11 @@ EOF
```
curl --location --request GET '127.0.0.1:18083/router-test'
```
因为请求头不为gray所以请求将会被路由到v1版本返回如下
因为请求头不为v2所以请求将会被路由到v1版本返回如下
```
Route in 30.221.132.228: 18081,version is v1.
```
之后发送一条请求头tag为gray的HTTP请求
之后发送一条请求头tag为v2的HTTP请求
```
curl --location --request GET '127.0.0.1:18083/router-test' --header 'tag: v2'
```
@ -363,7 +363,7 @@ curl --location --request GET '127.0.0.1:18083/router-test' --header 'tag: v2'
```
Route in 30.221.132.228: 18082,version is v2.
```
停止v2版本的ProviderApplication后继续发送一条请求头tag为gray的HTTP请求
停止v2版本的ProviderApplication后继续发送一条请求头tag为v2的HTTP请求
```
curl --location --request GET '127.0.0.1:18083/router-test' --header 'tag: v2'
```

@ -58,7 +58,7 @@ public void getDataFromControlPlaneTest() {
routeRule.setType("header");
routeRule.setCondition("=");
routeRule.setKey("tag");
routeRule.setValue("gray");
routeRule.setValue("v2");
RouteRule routeRule1 = new UrlRule.Parameter();
routeRule1.setType("parameter");
routeRule1.setCondition(">");
@ -84,7 +84,7 @@ public void getDataFromControlPlaneTest() {
}
```
The rules corresponding to the code are as follows:
If the request parameter contains tag=gray and the request header contains id and the value is greater than 10, uri is `/router-test` at the same time, the traffic is routed to the v2 version. If one of the request parameters does not meet the requirement, the traffic is routed to the v1 version.
If the request parameter contains tag=v2 and the request header contains id and the value is greater than 10, uri is `/router-test` at the same time, the traffic is routed to the v2 version. If one of the request parameters does not meet the requirement, the traffic is routed to the v1 version.
Rules also support dynamic modification. The rules for testing dynamic modification are as follows:
```java
@ -101,7 +101,7 @@ public void getDataFromControlPlaneTest() {
routeRule.setType("header");
routeRule.setCondition("=");
routeRule.setKey("tag");
routeRule.setValue("gray");
routeRule.setValue("v2");
RouteRule routeRule1 = new UrlRule.Parameter();
routeRule1.setType("parameter");
routeRule1.setCondition(">");
@ -129,7 +129,7 @@ public void getDataFromControlPlaneTest() {
}
```
The rules corresponding to the code are as follows:
If the request parameter contains tag=gray, and the request header contains id and the value is greater than 10, URL is `/router-test`, 50% of the traffic is routed to the v2 version, and the rest is routed to the v1 version. If one of the traffic does not meet the requirements, the traffic is routed to the v1 version.
If the request parameter contains tag=v2, and the request header contains id and the value is greater than 10, URL is `/router-test`, 50% of the traffic is routed to the v2 version, and the rest is routed to the v1 version. If one of the traffic does not meet the requirements, the traffic is routed to the v1 version.
##### demonstration Steps
1. visit http://localhost:18083/add Push the routing rules from the control surface interface to the routing rule warehouse
@ -137,7 +137,7 @@ If the request parameter contains tag=gray, and the request header contains id a
```
Route in 30.221.132.228: 18081,version is v1.
```
visit http://localhost:18083/router-test?id=11 and the key-tag which value set in the request header is gray, which meets the routing rules. The route is to the v2 version. The v2 version instance prints and returns the following results:
visit http://localhost:18083/router-test?id=11 and the key-tag which value set in the request header is v2, which meets the routing rules. The route is to the v2 version. The v2 version instance prints and returns the following results:
```
Route in 30.221.132.228: 18082,version is v2.
```
@ -147,7 +147,7 @@ If the request parameter contains tag=gray, and the request header contains id a
```
Route in 30.221.132.228: 18081,version is v1.
```
visit http://localhost:18083/router-test?id=11 and the key-tag which value set in the request header is gray, which meets the routing rules. 50% of the routes are routed to the v2 version. The v2 version instance prints the following results:
visit http://localhost:18083/router-test?id=11 and the key-tag which value set in the request header is v2, which meets the routing rules. 50% of the routes are routed to the v2 version. The v2 version instance prints the following results:
```
Route in 30.221.132.228: 18082,version is v2.
```
@ -252,7 +252,7 @@ spec:
- match:
- headers:
tag:
exact: gray
exact: v2
uri:
exact: /istio-label-routing
route:
@ -265,19 +265,19 @@ spec:
subset: v1
EOF
```
This VirtualService specifies the simplest label routing rule. HTTP requests with a gray header and `/istio-label-routing` path are routed to v2, and the rest of the traffic is routed to v1:
This VirtualService specifies the simplest label routing rule. HTTP requests with a v2 header and `/istio-label-routing` path are routed to v2, and the rest of the traffic is routed to v1:
### Demonstration effect
We send an HTTP request without a request header to IstioConsumerApplication:
```
curl --location --request GET '127.0.0.1:18084/istio-label-routing'
```
Since the request header is not gray, the request will be routed to version v1 with the following result:
Since the request header is not v2, the request will be routed to version v1 with the following result:
```
Route in 30.221.132.228: 18081,version is v1.
```
We then send an HTTP request with a gray tag in its header and the request path is `/istio-label-routing`:
We then send an HTTP request with a v2 tag in its header and the request path is `/istio-label-routing`:
```
curl --location --request GET '127.0.0.1:18084/istio-label-routing' --header 'tag: gray'
curl --location --request GET '127.0.0.1:18084/istio-label-routing' --header 'tag: v2'
```
The request is routed to version v2 because the routing rule is matched by the request:
```
@ -343,18 +343,18 @@ spec:
subset: v1
EOF
```
This [TrafficRouter](https://github.com/opensergo/opensergo-specification/blob/main/specification/en/traffic-routing.md) specifies the simplest label routing rule. HTTP requests with a gray header are routed to v2, and the rest of the traffic is routed to v1.
This [TrafficRouter](https://github.com/opensergo/opensergo-specification/blob/main/specification/en/traffic-routing.md) specifies the simplest label routing rule. HTTP requests with a v2 header are routed to v2, and the rest of the traffic is routed to v1.
If the version v2 does not have a corresponding instance, the HTTP request will fall back to the version v1.
### Demonstrate effect
We send an HTTP request without a request header to OpenSergoConsumerApplication
```
curl --location --request GET '127.0.0.1:18083/router-test'
```
Since the request header is not gray, the request will be routed to version v1 with the following result
Since the request header is not v2, the request will be routed to version v1 with the following result
```
Route in 30.221.132.228: 18081,version is v1.
```
We then send an HTTP request with a gray tag in its header and the request path is `/router-test`:
We then send an HTTP request with a v2 tag in its header and the request path is `/router-test`:
```
curl --location --request GET '127.0.0.1:18083/router-test' --header 'tag: v2'
```
@ -362,7 +362,7 @@ The request is routed to version v2 because the routing rule is matched by the r
```
Route in 30.221.132.228: 18082,version is v2.
```
After we stop the ProviderApplication of the version v2, we send an HTTP request with the request header tag gray.
After we stop the ProviderApplication of the version v2, we send an HTTP request with the request header tag v2.
```
curl --location --request GET '127.0.0.1:18083/router-test' --header 'tag: v2'
```

Loading…
Cancel
Save