2

问题:

/ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network unreachable

示例容器ifconfig

eth0      Link encap:Ethernet  HWaddr F2:3D:87:30:39:B8
      inet addr:10.2.8.64  Bcast:0.0.0.0  Mask:255.255.255.0
      inet6 addr: fe80::f03d:87ff:fe30:39b8%32750/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
      RX packets:22 errors:0 dropped:0 overruns:0 frame:0
      TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:4088 (3.9 KiB)  TX bytes:648 (648.0 B)

eth1      Link encap:Ethernet  HWaddr 6E:1C:69:85:21:96
      inet addr:172.16.28.63  Bcast:0.0.0.0  Mask:255.255.255.0
      inet6 addr: fe80::6c1c:69ff:fe85:2196%32750/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:18 errors:0 dropped:0 overruns:0 frame:0
      TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:1418 (1.3 KiB)  TX bytes:648 (648.0 B)

lo        Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1%32750/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

容器内路由:

/ # ip route show
10.2.0.0/16 via 10.2.8.1 dev eth0
10.2.8.0/24 dev eth0  src 10.2.8.73
172.16.28.0/24 via 172.16.28.1 dev eth1  src 172.16.28.72
172.16.28.1 dev eth1  src 172.16.28.72

主机iptables: http: //pastebin.com/raw/UcLQQa4J

主机ifconfig: http: //pastebin.com/raw/uxsM1bx6

记录flannel

main.go:275] Installing signal handlers
main.go:188] Using 104.238.xxx.xxx as external interface
main.go:189] Using 104.238.xxx.xxx as external endpoint
etcd.go:129] Found lease (10.2.8.0/24) for current IP (104.238.xxx.xxx), reusing
etcd.go:84] Subnet lease acquired: 10.2.8.0/24
ipmasq.go:50] Adding iptables rule: FLANNEL -d 10.2.0.0/16 -j ACCEPT
ipmasq.go:50] Adding iptables rule: FLANNEL ! -d 224.0.0.0/4 -j MASQUERADE
ipmasq.go:50] Adding iptables rule: POSTROUTING -s 10.2.0.0/16 -j FLANNEL
ipmasq.go:50] Adding iptables rule: POSTROUTING ! -s 10.2.0.0/16 -d 10.2.0.0/16 -j MASQUERADE
vxlan.go:153] Watching for L3 misses
vxlan.go:159] Watching for new subnet leases
vxlan.go:273] Handling initial subnet events
device.go:159] calling GetL2List() dev.link.Index: 3
vxlan.go:280] fdb already populated with: 104.238.xxx.xxx 82:83:be:17:3e:d6
vxlan.go:280] fdb already populated with: 104.238.xxx.xxx 82:dd:90:b2:42:87
vxlan.go:280] fdb already populated with: 104.238.xxx.xxx de:e8:be:28:cf:7a
systemd[1]: Started Network fabric for containers.
4

4 回答 4

2

如果您使用 upstreamNameServers 设置配置映射是可能的。

例子:

apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-dns
  namespace: kube-system
data:
  upstreamNameservers: |
    ["8.8.8.8", "8.8.8.4"]

在您的部署定义中添加:

dnsPolicy: "ClusterFirst"

更多信息在这里:

https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers

于 2018-06-22T14:43:35.337 回答
1

不可能让它工作,因为它还没有实现......我想我正在切换到 docker......

编辑:...或不,从法兰绒切换到印花布,它工作正常。

rkt #862
k8s #2249

于 2016-05-07T13:26:11.387 回答
1

Flannel 项目上的这个GitHub 问题--ip-masq=false可能会提供一个解决方案 - 基本上,尝试在您的 Docker 守护程序上禁用 IP 伪装 ( ),并--ip-masq在您的 Flannel 守护程序上启用它 ( )。

当我无法8.8.8.8从 Kubernetes 集群中的容器内部 ping 互联网 IP(例如)时,此解决方案对我有用。

于 2016-12-02T02:11:06.797 回答
0

尝试检查Kube-flannel.yml文件以及创建集群的启动命令kubeadm init --pod-network-cidr=10.244.0.0/16并且默认情况下在此文件中kube-flannel.yml你会得到10.244.0.0/16 IP,所以如果你想改变 pod-network-CIDR 那么请在文件中也进行更改。

于 2020-09-18T07:51:09.643 回答