OpenShift and hostnetwork = true

I deployed two PODs with the host network set to true. When PODs are deployed on the same OpenShfit node, then everything works fine, since they can discover each other using node IP.

When POD-s are deployed on different OpenShift nodes, they cannot find each other, I do not get any route for the host if I want to point one POD to another using node IP. How to fix it?

+5
source share
2 answers

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.

0
source

If you absolutely need to use the host network, you must create a router, and then use these routers to communicate between the containers. You can create a router based on the ha proxy server in opeshift, here the link is https://docs.openshift.com/enterprise/3.0/install_config/install/deploy_router.html

0
source

Source: https://habr.com/ru/post/1272605/


All Articles