mongo-k8s-sidecar
mongo-k8s-sidecar copied to clipboard
Fix nodes in replicaset unable to talk to each other
By default mongod command starts the daemon and binds to 127.0.0.1:27017
. This is a problem because, port 27017 on every node is unreachable from every other node. This can be tested by creating the stateful cluster on kubernetes and trying to run db queries by logging into one of the nodes, for example kubectl exec -it mongo-0 -- mongo --host mongo-0.mongo,mongo-1.mongo,mongo-2.mongo
. By passing the flag --bind_ip_all
, the nodes are able to talk to each other.
Since there's no versioning in place for choosing a specific MongoDB image version, it uses the lastest one, and after MongoDB v.42 both last flags for the command section of the Mongo container are deprecated and force a backOff error where the container is not able to be created. Please remove those flags or use versioning for the image.