Kubernetes POD无法解析Internet地址

wkyowqbh  于 6个月前  发布在  Kubernetes
关注(0)|答案(1)|浏览(69)

我已经在我的家庭实验室中使用Ubuntu 16.04上的kubeadm构建了一个Kubernetes集群,其中1个主节点和2个节点使用Calico作为CNI。所有节点都可以在其控制台上解析Internet地址,但我注意到的问题是我部署的Pod无法访问Internet。CoreDNS似乎工作正常。也就是说,我需要在Kubernetes集群上执行或配置任何特定操作,以便pods可以访问Internet。部署默认情况下可以访问Internet?

cloudadmin@vra-vmwlab-cloud-vm-318:~$ kubectl exec -ti busybox -- nslookup kubernetes.default
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
Name:      kubernetes.default
Address 1: 10.96.0.1 kubernetes.default.svc.cluster.local
cloudadmin@vra-vmwlab-cloud-vm-318:~$ kubectl exec -ti busybox -- ping google.com
ping: bad address 'google.com'
from the busybox Pod i can see its pointing to the right dns ip but still it cant reach google.com as you see above
cloudadmin@vra-vmwlab-cloud-vm-318:~$ kubectl exec -ti busybox -- sh
/ # cat /etc/resolv.conf

nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local vmwlab.local
options ndots:5
gab6jxml

gab6jxml1#

问题已解决..
在文档https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/中,它提到了以下内容:

Letting iptables see bridged traffic 
Make sure that the br_netfilter module is loaded. This can be done by running lsmod | grep br_netfilter. To load it explicitly call sudo modprobe br_netfilter.

As a requirement for your Linux Node's iptables to correctly see bridged traffic, you should ensure net.bridge.bridge-nf-call-iptables is set to 1 in your sysctl config, e.g.

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system

字符串
我还选择使用Weave Net而不是Calico作为CNI

相关问题