Unable to expose mongodb replicaset to nodeport Kubernetes



Could you please suggest a functional solution? I’m trying, like several other people I imagine, to expose my MongoDB replica set on the NodePorts of my Kubernetes cluster so that I can connect other components of my infrastructure (outside Kubernetes) to my database.

I’ve tried exposing the pods of my replica set via the options in the cr.yaml file

Steps to Reproduce:

enabled: true
exposeType: NodePort


i’m using version v1.15.0 of the cr.yaml. However, when I attempt to connect, I always get this type of error:


“MongoNetworkError: getaddrinfo ENOTFOUND test1-mongodb-rs0-0.test1-mongodb-rs0.test1-mongo.svc.cluster.local”

After researching, I feel like I’m in the same situation as here: Connection to an exposed replicaset is not working and here: Connection Issues When Accessing MongoDB Replica Set from Outside the Kubernetes Cluster.

What is the solution for this to work, please?

Seems we need to make our expose doc clearer :slight_smile:

The secret souce here would be adding the following:

clusterServiceDNSMode: External

Read more here: Exposing the cluster - Percona Operator for MongoDB