Search code examples
istio

How istio do weight-based tcp traffic shifting?


The offical doc show a weight-based tcp traffic routing, I'm curious about how istio done this job due to tcp is streaming data, there is no delimiter in it. istio have no idea about what tcp data it will gets.

So I look into the example code found the destination go server use byte('\n') as delimeter. Does this mean istio tcp traffic routing(exclude the port forwarding which don't need inspect the data content) require user tcp data must use '\n' as delimeter?


Solution

  • envoy is incapable of routing custom defined L4 traffic. Its L4 traffic routing is only used for http, as the definition of http data format, string end with a \n is a legal Simple-Request, that's why the sample works fine.

    The custom defined filters do encode and decode in Envoy::Networks::ReadFilter::onData and Envoy::Networks::WriteFilter::onWrite respectively. However, those 2 functions pass nothing to envoy about the knowledge of packet. That means envoy can not do traffic management on those custom defined tcp stream, for example, redirect to another pod