SCG中支持简单的灰度功能,可以根据配置分配流量。
配置
关键配置项目:- Weight={group}, {weigth}
- application:需要分流的组名
- weigth:流量百分比,最大值100.
spring:
application:
name: fw-gateway
cloud:
gateway:
routes:
- id: r_hi
uri: lb://hi
predicates:
- Path=/hi
#hi_test的流量权重
- Weight=hi_test, 99
- id: r_hi_t
uri: lb://hi-new
predicates:
- Path=/hi
#hi_test的流量权重
- Weight=hi_test, 1
- WeightCalculatorWebFilter: 在请求header中添加routeWeight分流表示
- WeightRoutePredicateFactory:根据routeWeight标示匹配路由