API Pod无法连接到同一个kubernetes群集中的mongo pod

我在一个由kubernetespipe理的Google计算引擎上运行一个nodejs api作为一个pod。 API正在连接到数据库,但之后突然显示此错误失败:

listening to http server on 0.0.0.0:8080... events.js:160 throw er; // Unhandled 'error' event ^ MongoError: failed to connect to server [mongo:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo mongo:27017] at Pool.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:328:35) at emitOne (events.js:96:13) at Pool.emit (events.js:188:7) at Connection.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:274:12) at Connection.g (events.js:292:16) at emitTwo (events.js:106:13) at Connection.emit (events.js:191:7) at Socket.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:177:49) at Socket.g (events.js:292:16) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at connectErrorNT (net.js:1021:8) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9) 

我试图重新启动prods,删除并重新创build容器,但没有成功?

这是我如何连接到数据库:

 mongoose.connect(process.env.MONGO_DEV_URL || process.env.MONGODB_URI || 'mongodb://mongo:27017:yaxiDb/yaxiDb', { useMongoClient: true }); 

我怎样才能debugging这个,哪里可能是问题?

       

网上收集的解决方案 "API Pod无法连接到同一个kubernetes群集中的mongo pod"