I am using stable-mongodb-replicaset helm chart for creating mongodb inside my k8s cluster hosted on Azure. mongodb has three replicas.stable-mongodb-replicaset acts as an sub chart.
my release name is skeleton. i can see my mongodb replicaset is up and running. i tried connection for it and it also works fine. as per documentation i tried connecting to this replicaset with service client but it throws error.
URL i am using for connection is
"mongodb://myuser:mydbpwd@skeleton-mongodb-replicaset-client:27001/skeleton?authSource=admin&replicaSet=rs0"
output of mongodb service
[1;30m2019-04-28 14:34:34,483 [0;39m => [34mINFO [0;39m [ [32mlocalhost-startStop-1 [0;39m] [33mcom.mongodb.diagnostics.logging.SLF4JLogger [0;39m: Cluster created with settings {hosts=[skeleton-mongodb-replicaset-client:27001], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[1;30m2019-04-28 14:34:34,485 [0;39m => [34mINFO [0;39m [ [32mlocalhost-startStop-1 [0;39m] [33mcom.mongodb.diagnostics.logging.SLF4JLogger [0;39m: Adding discovered server skeleton-mongodb-replicaset-client:27001 to client view of cluster
[1;30m2019-04-28 14:34:34,984 [0;39m => [34mINFO [0;39m [ [32mcluster-ClusterId{value='5cc5b9fab13658000122961a', description='null'}-skeleton-mongodb-replicaset-client:27001 [0;39m] [33mcom.mongodb.diagnostics.logging.SLF4JLogger [0;39m: Exception in monitor thread while connecting to server skeleton-mongodb-replicaset-client:27001
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.netty.NettyStream$2.operationComplete(NettyStream.java:158)
at com.mongodb.connection.netty.NettyStream$2.operationComplete(NettyStream.java:145)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483)
we are using driver org.mongodb:mongodb-driver-async 3.6.4 version while mongodb version we are using is 4.0
The headless service is used to control the network domain. As each pod is created, it gets a matching DNS subdomain, taking the form: $(podname).$(governing service domain) Therefore to connect to the replicaset I believe you need to use: "mongodb://myuser:mydbpwd@skeleton-mongodb-replicaset-0.skeleton-mongodb-replicaset:27001,skeleton-mongodb-replicaset-1.skeleton-mongodb-replicaset:27001,skeleton-mongodb-replicaset-2.skeleton-mongodb-replicaset:27001/?authSource=admin&replicaSet=rs0"
And to second @yanivoliver's question - why non-standard port?