Hi,
I’ve installed Percona Server for MongoDB using the official operator. I noticed that by default, a headless ClusterIP service is created that points to all MongoDB replicas.
I also saw that it’s possible to enable the creation of a service for each replica using the following configuration:
replsets:
rs0:
expose:
enabled: true
My question is: what is the recommended way to connect to MongoDB and ensure a reliable connection?
Should I use a connection string like this, pointing to the headless service:
mongodb://username:password@mongodb-rs0:27017/?replicaSet=rs0
Or should I explicitly list all replicas, like this:
mongodb://username:password@mongodb-rs0-0:27017,mongodb-rs0-1:27017,mongodb-rs0-2:27017/?replicaSet=rs0
Which approach is considered best practice in a Kubernetes environment with Percona Server for MongoDB?
Thanks in advance for your advice!