Connecting to an external MongoDB replica-set from GKE

7/31/2019

I have set up a cluster in GKE. I have configured it to deploy a Docker image which is running a MeteorJS app that connects to a hosted MongoDB service via a replica-set.

The connection string URI is:

mongodb://[username]:[password]@[host1]:20210,[host2]:20210,[host3]:20210/[database]?ssl=true

When my pods boot up they get into a crash loop and continuously report:

MongoError: no mongos proxy available at Timeout. (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/mongos.js:759:28)

I have read that a GKE cluster has cluster-local DNS and so I configured ExternalName services for each replica-set host (i.e.: I updated the connection URI to have host aliases and mapped them to external domains).

But this had no effect and the error remains.

I feel like I must be missing something here. Connecting from my local machine this way works. We are also running a Docker Swarm on Azure and the app is able to connect from there also.

Is anyone able to shed some light on how GKE is different here? Am I missing a step?

Many thanks, Ben

Edit: I updated my connection string to reference IP addresses rather than domain names. The problem persisted, so perhaps this is not a DNS issue.

I also deployed a Load Balancer to expose the pods in my cluster in the hope that would help. Although I did not expect it to, and it didn't.

-- benjimix
google-kubernetes-engine
mongodb

0 Answers