【问题标题】:Kubernetes PODs cant Resolve Internet addressesKubernetes POD 无法解析 Internet 地址
【发布时间】:2021-01-11 21:07:18
【问题描述】:

我在我的家庭实验室 1 个主节点和 2 个节点中使用 kubeadm 在 Ubuntu 16.04 上构建了一个 Kubernetes 集群,其中 Calico 作为 CNI。所有节点都可以在其控制台上解析互联网地址,但我注意到我部署的 pod 无法访问互联网的问题。 CoreDNS 似乎工作正常。话虽如此,我需要在 Kubernetes 集群上执行或配置什么特定操作,以便我部署的 pod 默认可以访问互联网?

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

对此的任何帮助表示赞赏。谢谢

【问题讨论】:

  • 我会尝试完成这里的步骤:kubernetes.io/docs/tasks/administer-cluster/…
  • 您的节点是否设置了防火墙规则来阻止传出流量?我认为@Howard_Roark 有一个很好的观点,检查常见问题始终是第一步。在那之后......有很多关于CNI的知识;)
  • 我已经完成了 Howard Roark 故障排除步骤。所有节点都禁用了固件,包括主节点。我可以从节点解决问题,但不能从我部署的 pod 解决
  • 1.你的kubernetes和calico版本是什么? 2.你能尝试在其他图像上进行这些测试,而不是busybox吗?据我检查herebusybox 没有正确遵守 DNS 设置。 3.你可以试试其他的CNI吗? 4.您是否将--pod-network-cidr 添加到您的kubeadm init 命令中?

标签: kubernetes coredns


【解决方案1】:

问题已解决..

在文档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

我还选择使用 Wea​​ve Net 而不是 calico 作为 CNI

【讨论】:

    猜你喜欢
    • 2020-03-15
    • 2020-02-13
    • 2020-11-02
    • 2019-09-16
    • 2023-02-22
    • 1970-01-01
    • 1970-01-01
    • 2018-11-04
    • 2020-08-06
    相关资源
    最近更新 更多