Hi, community, we are using istio for service mesh and I'm looking for solution about dynamic routing based on header with istio proxy / envoy
- Use case
during testing a service A, we want to mock some of its upstream dependencies. A normal request route is like 'req -> A -> real_dependency:8080', and we expect to pass some header like 'REQ-DYNAMIC-ROUTING: real_dependency:8080=dependency_mocker:9090' in a request which indicates if A requests 'real_dependency:8080' during serving this request, and envoy proxy should change the route to 'req -> A -> dependency_mocker:9090'. Note the real_dependency and dependency_mocker passed in header can be changed according to the test cases
- Some explorations
according to the
post (I checked the 'ignore_port_in_host_matching' which is set to true), I've tried envoy lua filter to change 'host' header, but if the port of real_dependency and port of dependency_mocker are different, a PassthroughCluster will be matched and the dynamic routing failed.
I've reproduced the issue with istio's productpage demo, and attached config and logs (search 'PassthroughCluster' match for URL '/details/0')
Can I ask some lights about how this feature can be implemented? is it possible with lua filter? Thanks!