1. istio-proxy
istio-proxy 注入时会从istio-sidecar-injector中获取需要被拦截outbound的IP地址范围,定位于configmap中的includeOutboundIPRanges,默认值是*,即拦截所有出口流量。
通过istio VirtualService配置,将请求header中包含某个key:value的转发的其他的接口版本中,需要将header中的这个值传递到feignclient调用的后续服务中。例如将header中包含end-user,值为jason的转到reviews v3,其他的v2。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- match:
- headers:
end-user:
exact: jason
route:
- destination:
host: reviews
subset: v2
- route:
- destination:
host: reviews
subset: v3
2. Feignclient Headers
springboot中feignclient可以通过实现RequestInterceptor来设置feignclient的请求头。百度FeignClient传递headers都采用如下实现。
@Configuration
public class FeignClientRequestInterceptor implements RequestInterceptor {
private sta