I am running a mongodb replica set as containers in Mesos cluster ( My question also applied to k8s/swarm). The replica set can be initialized using DNS or container IPs. But, both DNS or container IPs can be accessed only in the overlay network of the Mesos cluster. Now, users want to access the mongo replica set from outside the Mesos/K8s cluster, how can they achieve this through an ingress/marathon-lb?
Not to consider HostPort here, because only the ingress/lb nodes are exposed to the public network.
Ingress controller is using HTTP
and it does not support TCP
. MongoDB require regular TCP/IP
socket.
There are two other ways to achieve that:
NodePort
or Loadbalancer
service. If this runs on cloud then you can use loadbalancer, otherwise use NodePort
. More information about services can be found here.Both solution are explained in this Mongodb tutorial