Reputation: 1773
I am trying to access a host that sits in another server (but on my network) from inside the pod of deployment and I am using microk8s
.
The thing is that on the server where I have microk8s
installed I can easily ping it by ping my-network-host.qa.local
. But when I go inside the pod with microk8s kubectl exec -it pod_name -- /bin/bash
and I do ping my-network-host.qa.local
it says: Name or service not known
.
And when I connect to a VPN on my computer to be on that network and I deploy it locally using docker-desktop kubernetes
I can ping that host from within the pod. So I think the problem sits in microk8s
which is not letting my pod use my network.
Is there any way to tell microk8s to use my hosts from my network?
p.s. I can ping the ip
of that server from the pod, but I am not being able to ping the host from the pod
Upvotes: 4
Views: 4810
Reputation: 1773
Based on another answer that I found on StackOverflow, i managed to fixed it.
There were 2 changes needed to make it work:
Update kubelet configuration to use resolv-conf
:
sudo echo "--resolv-conf=/run/systemd/resolve/resolv.conf" >> /var/snap/microk8s/current/args/kubelet
Restart kubelet service:
sudo service snap.microk8s.daemon-kubelet restart
Then change the CoreDNS forward to point to your nameserver:
First open coredns config map so you can edit it
sudo microk8s.kubectl edit configmap coredns -n kube-system
and update the file at
forward . 8.8.8.8 8.8.4.4 #REMOVE THIS LINE
forward . xxx.xxx.xxx.xxx #ADD THIS WITH YOUR IP
You can get eth0 DNS address:
nmcli dev show 2>/dev/null | grep DNS | sed 's/^.*:\s*//'
On my case I already had the ip as nameserver on /run/systemd/resolve/resolv.conf
.
Now just save the changes, and go inside your pods so you will be able to access them.
There is a comment in another post that suggest adding
forward . /etc/resolv.conf
But that didnt work on my case.
Upvotes: 3