MongoError: no mongos proxy available

3/18/2019

I am running a MongoDB service in Kubernetes and I am trying to connect with MongoDB service to another back-end services. I deployed MongoDB service to following codelabs tutorial. here is the tutorial link

https://codelabs.developers.google.com/codelabs/cloud-mongodb-statefulset/index.html?index=..%2F..index#8)

MongoDB service is running properly and I can create a database through a shell command.

when I try to connect with nodejs back-end using mongoose I am getting below error

MongoError: no mongos proxy available

here is my mongos connection URL

mongodb://mongo-0.mongo,mongo-1.mongo,mongo-2.mongo:27017/food_content

-- Rubel hasan
gcloud
kubernetes
mongodb
mongoose

1 Answer

3/18/2019

First of all that tutorial was last updated on Feb/2017. I recommend you to read a more recent tutorial.

You should read about how Services work. In particular, according to this doc you can access a service through

$(service name).$(namespace).svc.cluster.local

And a Pod with:

$(podname).$(service name).$(namespace).svc.cluster.local

Example:

mongo-0.mongo.default.svc.cluster.local
-- victortv
Source: StackOverflow