@ -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
@ -108,4 +125,4 @@ We use Istio to publish corresponding `AuthorizationPolicy` and `RequestAuthenti
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: