localhost Pod to Pod communication k8s I am trying to transfer an old legacy system to k8s.

I have a custom server that client apps connect to in order to communicate with one another. Both the server and clients were originally created to run on the same system and communicate using localhost. 

I Dockerized both server and client apps. I tested that they work well in the same pod (everything runs well using localhost). Now I would like to separate the server and apps into their own pods. I would like the apps to automatically connect to the server. 

Question: How do I connect the client apps to the server without changing the source code of the client apps or server?
Are you basically saying that it’s hard coded to “localhost” and you need to somehow change the meaning of “localhost” because you cannot change the source code?

If so, it sounds fairly hard to achieve... but maybe you can override the meaning of localhost in the hosts file of the pod (the right way).

https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/

I feel like this will probably have unintended side effects and may affect kubernetes, but I could be wrong.  It’s definitely worth a try.

Note: the overrides can point to services created over the pod deployments if it works :).  They can have reliable internal domain names that don’t move around.