If you want two containers to share the same physical machine and use a loop for fast communication, then you would be better off defining them together as a single Pod with two containers.
If two containers are designed to navigate a larger cluster and are looser connected to each other, I would recommend using the Service construction in Kubernetes (in OpenShift) and using this for appropriate detection.
The services are documented at https://kubernetes.io/docs/concepts/services-networking/service/ and together with the internal DNS service (if implemented, distributed in Kubernetes 1.4 and later), they provide tools that allow Kubernetes to control what happens by updating the internal DNS record in the form <servicename>.<namespace>.svc.cluster.local . For example, if you created a Pod with a service named "backend" in the default namespace, another Pod might refer to it as backend.default.svc.cluster.local . Kubernetes DNS documentation for this can be found at https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
It also eliminates the complexity of "hostnetwork = true" and allows OpenShift (or Kubernetes in particular) to manage the network.
source share