DEV Community

Jashua
Jashua

Posted on

Microk8s Kubernetes - How do I connect two services?

I'm using Microk8s Kubectl in Ubuntu server, I was following some tutorials from Nana's YouTube channel and she explained, for example, how to connect a Mongo Express service to a MongoDB service, however I'm getting an error.

I actually used her files provided here and the problem persists, so I wonder if I have to do anything extra in Microk8s.

Error shown in Mongo Express logs (using her files):

/docker-entrypoint.sh: line 14: mongodb-service: Try again
/docker-entrypoint.sh: line 14: /dev/tcp/mongodb-service/27017: Invalid argument
retrying to connect to mongodb-service:27017

Any help is welcome, thank you very much :)

FIXED

The problem was the coredns deployment wasn't working properly, pod shown as 0/1, you can check these by running: get all --namespace kube-system, therefore Mongo Express wasn't finding MongoDB by the DNS.

I found the following command that displayed some other problems: microk8s.inspect

Then I did as the inspection suggested:
sudo ufw allow in on cni0
sudo ufw allow out on cni0
sudo apt install iptables-persistent

Upon doing so everything worked correctly!

Top comments (4)

Collapse
 
babs232 profile image
Biswajyoti Chowdhury

Faced the same issue. The calico pod status helped. Thanks for the insight!

Cheers!

Collapse
 
prashanthmgvr profile image
Prashanth Mogaveera

yes, I have faced the same issue, Thanks for the fix. As I'm trying in local I disabled ufw and restarted microk8s, then it got worked.

Collapse
 
mehdiwadoud profile image
mehdiwadoud

had the same issue thank you so much for the help

Collapse
 
junihoj profile image
Eze Onyekachukwu • Edited

how will i do this on windows? i am using docker as a my driver for minikube