Skip to content
Advertisement

Local Mongo DB Container Access with Kubernetes Service Endpoint in K3s is not working

Earlier I used earlier kubeadm to create an endpoint from my local MongoDB which is running in a Docker container, now we have switched from kubeadm to k3s because it is a lot of easier to use. Now we are not able to use the MongoDB endpoints, it is reachable inside the Kubernetes cluster. I will share the necessary information for you. Would be glad if anybody can help me.

  1. This is the Mongo DB container which is running inside usual Docker: enter image description here

  2. Now I would like use it in my Kubernetes cluster, before I did a check if I am able to access inside the port 27019 and it seems to be fine.

JavaScript
  1. Add next I created the Endpoint and service file
JavaScript
JavaScript

And as next I used them for my environment variable as ConfigMap:

JavaScript

And bind it to my pod in deployment:

JavaScript

Now I am getting this issue, so the database can not find.

JavaScript

As I mentioned earlier in our kubeadm architecture it worked very fine now it is not working. And I checked as well if the MongoDB is in the node of K3s and yes, it is.

Advertisement

Answer

I found the solution, you can use directly the IP Address {address-of-the-VM}:27019.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement