Service Mesh: Using Istio to route TCP traffic based on Client IP in Virtual Service

ε祈祈猫儿з 提交于 2021-01-28 19:39:53

问题


Ingress gateway is located behind AWS ELB(classic) using nodeport and I want to route TCP traffic in Virtual Service based on client ip.

Of course Proxy Protocol of ELB is enabled.

When I use HTTP, it works. The configuration is below.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: app-vservice
  namespace: test
spec:
  hosts:
  - "app-service"
  http:
  - match:
    - headers:
        x-forwarded-for:
          exact: 123.123.123.123
    route:
    - destination:
        host: app-service
        subset: v2
  - route:
    - destination:
        host: app-service
        subset: v1

But I can't find headers field of TCP route in official documents.

Is it impossible?

Thank you.


回答1:


According to docs yes there is no field to pass headers in TCPRoute in Istio. Also to answer your question every header manipulation should be done using envoy filters because Istio, built on envoy supports that and also decreases the complexity.

Using envoy and lua filters as stated in Istio docs. It can be achieved. Please follow envoy docs.

Checkout the Istio Discussion for headers in Virtual Service.

For implementation of the same using Lua. And a blog showing an example how to implement filters on envoy.



来源:https://stackoverflow.com/questions/62207744/service-mesh-using-istio-to-route-tcp-traffic-based-on-client-ip-in-virtual-ser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!