update routing module docs (#3076)

* update routing module docs
pull/3082/head
HHoflittlefish777 2 years ago committed by GitHub
parent 7fec17101e
commit dbe8452833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -63,11 +63,6 @@ spring:
|NAMESPACE_NAME|metadata.namespace
|===
=== 使用标签路由
在引入配置转换模块后我们就能获取到相应的治理规则来对Spring Cloud应用赋予相应的治理能力。标签路由模块可以实现对Spring Cloud应用根据请求头请求参数等标签来路由到不同的服务
如果在您的项目中使用Spring Cloud Alibaba Governance 标签路由需要使用需要使用group ID 为 `com.alibaba.cloud` 和artifact ID 为 `spring-cloud-starter-alibaba-governance-routing` 的starter
=== 运行应用
需要将应用运行在K8s环境中并给运行的应用将K8s的一些元信息注入以下环境变量中:
@ -77,10 +72,22 @@ spring:
|NAMESPACE_NAME|metadata.namespace
|===
=== 使用标签路由
=== 路由
==== 组件支持说明
目前,路由模块只支持了部分组件:
远程调用组件Spring Cloud OpenFeign
负载均衡组件Ribbon
未来会支持更多的比如RestTemplateSpring Cloud LoadBalancer等组件。
==== 使用路由
在引入配置转换模块后我们就能获取到相应的治理规则来对Spring Cloud应用赋予相应的治理能力。标签路由模块可以实现对Spring Cloud应用根据请求头请求参数等标签来路由到不同的服务
如果在您的项目中使用Spring Cloud Alibaba Governance 标签路由需要使用需要使用group ID 为 `com.alibaba.cloud` 和artifact ID 为 `spring-cloud-starter-alibaba-governance-routing` 的starter
1.如果在您的项目中使用Spring Cloud Alibaba Governance 标签路由需要使用需要使用group ID 为 `com.alibaba.cloud` 和artifact ID 为 `spring-cloud-starter-alibaba-governance-routing` 的starter
[source,xml,indent=0]
----
<dependency>
@ -89,6 +96,12 @@ spring:
</dependency>
----
2.配置当没有路由规则时的负载均衡算法(以随机负载均衡算法为例)
如果没有配置使用ribbon默认的负载均衡算法ZoneAvoidanceRule
----
spring.cloud.governance.routeing.rule=RandomRule
----
在引入Istio配置转换模块的前提下标签路由模块支持对以下几种请求的元信息做路由
* 请求路径

@ -64,7 +64,18 @@ You need to run the application in the K8s environment and inject some meta info
|NAMESPACE_NAME|metadata.namespace
|===
=== Use Label Routing
=== Routing
==== Component support description
Currently, the routing module only supports some components:
Remote call Component: Spring Cloud OpenFeign
Load balance Component: Ribbon
In the future, more components such as RestTemplate, Spring Cloud LoadBalancer and so on will be supported.
==== use Routing
With the introduction of the configuration transformation module, we can obtain the governance rules to give the Spring Cloud application some governance capabilities. Label routing module can route the Spring Cloud application according to the request header, request parameters and other tags to route to different services.
If you use Spring Cloud Alibaba Governance Label Routing in your project, You need to use a starter with a group ID of `com.alibaba.cloud` and an artifact ID of `spring-cloud-starter-alibaba-governance-routing`.
@ -76,6 +87,12 @@ If you use Spring Cloud Alibaba Governance Label Routing in your project, You ne
</dependency>
----
2.Configure a load balance algorithm when there are no routing rules (RandomRule algorithm as an example)
If no configuration,use default ribbon load balance algorithm ZoneAvoidanceRule.
----
spring.cloud.governance.routeing.rule=RandomRule
----
With the introduction of Istio Resource Transform module, the label routing module supports routing of the following types of request meta-information:
* Request Path

@ -1,13 +1,22 @@
# label route example
# routing example
## 项目说明
本项目演示如何使用 spring cloud ailbaba governance labelrouting 模块完成标签路由功能。
本项目演示如何使用 spring cloud ailbaba governance routing 模块完成标签路由功能。
## 模块结构
本模块包括一个消费者实例和一个提供者集群,该集群包含着两个实例。
## 组件支持说明
目前,路由模块只支持了部分组件:
远程调用组件Spring Cloud OpenFeign
负载均衡组件Ribbon
未来会支持更多的比如RestTemplateSpring Cloud LoadBalancer等组件。
## 示例
### 如何接入
@ -20,6 +29,11 @@
<artifactId>spring-cloud-starter-alibaba-governance-routing</artifactId>
</dependency>
```
2.配置当没有路由规则时的负载均衡算法(以随机负载均衡算法为例)
如果没有配置使用ribbon默认的负载均衡算法ZoneAvoidanceRule
```yaml
spring.cloud.governance.routeing.rule=RandomRule
```
### 应用启动
@ -121,7 +135,7 @@ public void getDataFromControlPlaneTest() {
```
Route in 30.221.132.228: 18081,version is v1.
```
访问 http://localhost:18083/router-test?id=11 且请求头设置test值为gray 满足路由规则路由到v2版本中v2版本实例打印返回如下结果
访问 http://localhost:18083/router-test?id=11 且请求头设置tag值为gray 满足路由规则路由到v2版本中v2版本实例打印返回如下结果
```
Route in 30.221.132.228: 18082,version is v2.
```
@ -131,7 +145,7 @@ public void getDataFromControlPlaneTest() {
```
Route in 30.221.132.228: 18081,version is v1.
```
访问 http://localhost:18083/router-test?id=11 且请求头设置test值为gray 满足路由规则50%路由到v2版本中v2版本实例打印返回如下结果
访问 http://localhost:18083/router-test?id=11 且请求头设置tag值为gray 满足路由规则50%路由到v2版本中v2版本实例打印返回如下结果
```
Route in 30.221.132.228: 18082,version is v2.
```

@ -1,13 +1,23 @@
# label route example
# routing example
## Project Description
This project demonstrates how to use the spring cloud ailbaba governance labelrouting module to complete the label routing function.
This project demonstrates how to use the spring cloud ailbaba governance routing module to complete the label routing function.
## module structure
This module includes a consumer instance and a provider cluster, which contains two instances.
## Component support description
Currently, the routing module only supports some components:
Remote call Component: Spring Cloud OpenFeign
Load balance Component: Ribbon
In the future, more components such as RestTemplate, Spring Cloud LoadBalancer and so on will be supported.
## Example
### How to access
@ -21,6 +31,12 @@ This module includes a consumer instance and a provider cluster, which contains
</dependency>
```
2.Configure a load balance algorithm when there are no routing rules (RandomRule algorithm as an example)
If no configuration,use default ribbon load balance algorithm ZoneAvoidanceRule.
```yaml
spring.cloud.governance.routeing.rule=RandomRule
```
### Application Start
Start a startup class of three modules, ConsumerApplication and two ProviderApplications, and inject them into the Nacos registry.
@ -121,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 test 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 gray, 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.
```
@ -131,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 test 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 gray, 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.
```

Loading…
Cancel
Save