Spring Cloud Gateway 權重路由
使用場景:需要多版本服務控制的時候,需要對服務進行權重路由,最常見的場景就是一個服務有兩個版本V1,V2,在線上灰度的時候,需要忘光動態實時推送路由的權重信息,如95的流量到V1,5的流量到V2.
spring:
cloud:
gateway:
routes:
- id: service1_v1
uri: http://localhost:8081/v1
predicates:
- Path=/test
- Weight=service1, 95
- id: service1_v2
uri: http://localhost:8081/v2
predicates:
- Path=/test
- Weight=service1, 5
Weight=service1, 5 是權重設置