Accessing a service via localhost

We have some “legacy” services that assume other services are available via a local TCP port (e.g. localhost:1234). I’d like to put these services behind Istio, but how would I get Istio to route traffic such that hitting a port on localhost forwards to a given service?

I tried creating a Service and a VirtualService named “localhost”, but that does not work. I’m assuming this is because the sidecar injection adds some iptables rules to exclude traffic to localhost/127.0.0.1 from redirection to Istio/Envoy (as described in https://istio.io/latest/blog/2019/data-plane-setup/), but it’s not clear if this is definitely the case, or how to customize that behavior.

1 Like

As per my understanding, you need to specify the IP as localhost is very ambiguous when it comes to k8s cluster, btw which platform are you using?