Kubernetes through Virtualbox; Pods can't access internet services
System: VirtualBox, Debian 10 Server, Kubernetes with kubeadm
I've setup a deployment and a service and I am exposing it via NodePort but my Pods somehow cant access the internet. The worker node which runs the pod however has an internet connection. I tested this by exec into the running pod and curl a webpage.
Pods
root@master:/home/user# kubectl get pods
NAME READY STATUS RESTARTS AGE
my-website-6d8f7c7bfb-sdtrh 1/1 Running 1 6d1h
Curl from Host
root@master:/home/user# curl https://wikipedia.org
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.wikipedia.org/">here</a>.</p>
</body></html>
Exec Pod - Curl
root@master:/home/user# kubectl exec -it my-website-6d8f7c7bfb-sdtrh /bin/bash
root@my-website-6d8f7c7bfb-sdtrh:/sbin# curl https://wikipedia.org
curl: (6) Could not resolve host: wikipedia.org
Anyone an idea what that could be? I'm fairly new to DevOps, so I don't know quite as much about all of that yet.
EDIT for Howard_Roark
- I've checked and yes the two
/etc/resolv.conf
's differ.
On worker node
root@worker:~# cat /etc/resolv.conf
# Generated by NetworkManager
search fritz.box
nameserver 192.168.178.1
Inside Pod
/ # cat /etc/resolv.conf
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local fritz.box
options ndots:5
- From the node itself I can get out to another name server, but not from the pod.
root@worker:~# nslookup wikipedia.org 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: wikipedia.org
Address: 91.198.174.192
Name: wikipedia.org
Address: 2620:0:862:ed1a::1
root@worker:~# nslookup wikipedia.org 1.1.1.1
Server: 1.1.1.1
Address: 1.1.1.1#53
Non-authoritative answer:
Name: wikipedia.org
Address: 91.198.174.192
Name: wikipedia.org
Address: 2620:0:862:ed1a::1
- Is presumable gonna fail too hence 2. But I'll test it now.
Solution
The Problem disappeared after I moved to a proper development server. Apparently the Kubernetes cluster does not properly run with bridged AirPort network environments in Virutalbox.