googlecodelabs / feedback

Provide feedback to our codelabs by filing an issue here
18 stars 22 forks source link

[cloud-mongodb-statefulset]: MongoDB binds to localhost by default #435

Open areller opened 6 years ago

areller commented 6 years ago

You have to explicitly specify bind_ip, otherwise mongodb will bind to localhost and won't be able to communicate with other nodes and create a replica set

screen shot 2018-06-08 at 13 25 53
stigok commented 6 years ago

That sure took a while for me to figure out too. The upstream example files specifies --bind_ip correctly.

When it binds to localhost, you will get seemingly healthy pods while the sidecar goes in an error loop

Error in workloop { MongoError: failed to connect to server [10.244.0.67:27017] on first connect [MongoError: connect ECONNREFUSED 10.244.0.67:27017]
    at Pool.<anonymous> (/opt/cvallance/mongo-k8s-sidecar/node_modules/mongodb-core/lib/topologies/server.js:336:35)
    at Pool.emit (events.js:180:13)
    at Connection.<anonymous> (/opt/cvallance/mongo-k8s-sidecar/node_modules/mongodb-core/lib/connection/pool.js:280:12)
    at Object.onceWrapper (events.js:272:13)
    at Connection.emit (events.js:180:13)
    at Socket.<anonymous> (/opt/cvallance/mongo-k8s-sidecar/node_modules/mongodb-core/lib/connection/connection.js:189:49)
    at Object.onceWrapper (events.js:272:13)
    at Socket.emit (events.js:180:13)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at process._tickCallback (internal/process/next_tick.js:114:19)
  name: 'MongoError',
  message: 'failed to connect to server [10.244.0.67:27017] on first connect [MongoError: connect ECONNREFUSED 10.244.0.67:27017]' }
areller commented 6 years ago

@stigok In that case the actual code lab (as seen in the attached screenshot) is inconsistent with the upstream example files that you've mentioned because in the code lab itself they don't specify a bind-ip argument so it automatically binds to localhost.

screen shot 2018-07-02 at 12 00 20