<p>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</p>

<blockquote>
  <p><a href="https://codelabs.developers.google.com/codelabs/cloud-mongodb-statefulset/index.html?index=..%2F..index#8" rel="nofollow noreferrer">https://codelabs.developers.google.com/codelabs/cloud-mongodb-statefulset/index.html?index=..%2F..index#8</a>)</p>
</blockquote>

<p>MongoDB service is running properly and I can create a database through a shell command. </p>

<p>when I try to connect with nodejs back-end using <code>mongoose</code> I am getting below error</p>

<blockquote>
  <p>MongoError: no mongos proxy available</p>
</blockquote>

<p>here is my mongos connection URL </p>

<p><code>mongodb://mongo-0.mongo,mongo-1.mongo,mongo-2.mongo:27017/food_content</code></p>

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

<p>You should read about how <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Services</a> work.
In particular, <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-identity" rel="nofollow noreferrer">according to this doc</a> you can access a service through </p>

<pre><code>$(service name).$(namespace).svc.cluster.local
</code></pre>

<p>And a Pod with: </p>

<pre><code>$(podname).$(service name).$(namespace).svc.cluster.local
</code></pre>

<p>Example:</p>

<pre><code>mongo-0.mongo.default.svc.cluster.local
</code></pre>
