Kubernetes pod connection to MongoDB Atlas issues

6/21/2018

I have two pods in my Kubernetes cluster - one is connecting just fine to my MongoDB Atlas cluster, the other is failing due to the following exception:

Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. 
Client view of cluster state is {type=REPLICA_SET, servers=[{address=MY_MONGO_SERVER1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, {address=MY_MONGO_SERVER2:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}, {address=MY_MONGO_SERVER3:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]

Now I'm not sure why one pod is able to connect, while the second one fails. We have another environment (production) that has similar configuration and all is fine with that environment's pods. Also, that environment runs on same Atlas cluster-sized DB, with similarly configured Kubernetes deployments.

-- Jonathan Perry
kubernetes
mongodb
playframework

0 Answers