I Use rancher to create an cluster with Amazon EKS.
Deployed a nodejs app in ‘default’ namespace.
Installed MongoDB replicaset from the rancher app catalog with default settings.
- Service/Deployment name is mongodb-replicaset
- namespace is also mongodb-replicaset
When I use
mongodb://mongodb-replicaset:27017/tradeit_system?replicaSet=rs
as connection string.
I get the error.
MongoNetworkError: failed to connect to server [mongodb-replicaset-:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND mongodb-replicaset mongodb-replicaset:27017]
Then I read in kubernetes documentation that to access a service in a different namespace you need to also specify the namespace along with the service name.
So I did this
mongodb://mongodb-replicaset.mongodb-replicaset:27017/tradeit_system?replicaSet=rss
MongoError: no primary found in replicaset or invalid replica set name
Got same error with this as well.
mongodb://mongodb-replicaset.mongodb-replicaset.svc.cluster.local:27017/tradeit_system?replicaSet=rs