Enabling Kubernetes on Docker Desktop breaks access to external service

8/11/2020

I'm using docker desktop for mac.

I have built a docker image for a Node.js app that connects to an external MongoDB database via URI (the db is running on an AWS instance that I'm connected to over vpn). This works fine - I run the container and the app can connect to the database. Happy days.

Then...

I enable Kubernetes on docker desktop. I apply a deployment.yml to run the container but this deployment fails when trying to connect to the db. From my app's logs (I'm using mongoose):

MongooseServerSelectionError: connect EHOSTUNREACH [MY DB IP] +30005ms

Interestingly...

I can now no longer connect to the db by running my docker container either. I get the same error.

I have to disable kubernetes, restart docker desktop (twice), prune my previous container and network, and re-run my container. Then it will work again.

As soon as I enable kubernetes again, the db becomes unreachable again.

Any ideas why this is and/or how to fix it?

-- Daniel Loiterton
docker
docker-desktop
kubectl
kubernetes
networking

1 Answer

8/12/2020

So the issue for us turned out to be an IP range clash. Exactly the same as described in this SO question:

https://stackoverflow.com/questions/53590312/change-kubernetes-docker-for-desktop-cluster-network-ip

Unfortunately, like this user, we haven't been able to find a solution

-- Daniel Loiterton
Source: StackOverflow