Kubernetes - pod 没有从 Flannel CIDR 获取 IP
Kubernetes - pod is not getting IP from Flannel CIDR
我已经在工作节点上成功配置了 Flannel。当我在 worker 上执行 ifconfig
时,我看到一个 flannel.1
接口(我正在使用 vxlan)。还有 docker0
和 cbr0
接口。
但是,当 pod 启动时,该节点上的 docker 容器从 cbr0
接口获取 IP 地址,not 从 flannel 获取 IP 地址界面。我确实尝试手动删除 cbr0 接口,但是当 docker 容器被安排在 pod 出现的节点上时它又回来了。
Docker 是这样启动的:
dockerd --bip=10.200.50.1/24 --mtu=8951 --iptables=false --ip-masq=false --host=unix:///var/run/docker.sock --log-level=error --storage-driver=overlay
法兰绒环境:
$ cat /run/flannel/subnet.env
FLANNEL_NETWORK=10.200.0.0/16
FLANNEL_SUBNET=10.200.50.1/24
FLANNEL_MTU=8951
FLANNEL_IPMASQ=false
ifconfig
说:
$ ifconfig
cbr0 Link encap:Ethernet HWaddr 0a:58:0a:c8:04:01
inet addr:10.200.4.1 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::d99:edff:fec6:9dd0/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:536 (536.0 B) TX bytes:648 (648.0 B)
docker0 Link encap:Ethernet HWaddr 02:42:a4:4b:44:dc
inet addr:10.200.50.1 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 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)
eth0 Link encap:Ethernet HWaddr 12:e7:81:c3:1e:58
inet addr:10.0.2.152 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe90::10e8:86ff:fec3:1e58/54 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:9001 Metric:1
RX packets:911006 errors:0 dropped:0 overruns:0 frame:0
TX packets:821093 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:725362580 (725.3 MB) TX bytes:155420170 (155.4 MB)
flannel.1 Link encap:Ethernet HWaddr 12:10:54:76:3e:c4
inet addr:10.200.50.0 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::1410:54ff:fe86:3ec4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:8951 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:11 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:27 errors:0 dropped:0 overruns:0 frame:0
TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1624 (1.6 KB) TX bytes:1624 (1.6 KB)
如何确保 pod 的 IP 地址来自 flannel 接口?
您可能需要检查您的 kubernetes 部署,以确保您没有使用任何网络插件,因为您正在使用 flannel。
我已经在工作节点上成功配置了 Flannel。当我在 worker 上执行 ifconfig
时,我看到一个 flannel.1
接口(我正在使用 vxlan)。还有 docker0
和 cbr0
接口。
但是,当 pod 启动时,该节点上的 docker 容器从 cbr0
接口获取 IP 地址,not 从 flannel 获取 IP 地址界面。我确实尝试手动删除 cbr0 接口,但是当 docker 容器被安排在 pod 出现的节点上时它又回来了。
Docker 是这样启动的:
dockerd --bip=10.200.50.1/24 --mtu=8951 --iptables=false --ip-masq=false --host=unix:///var/run/docker.sock --log-level=error --storage-driver=overlay
法兰绒环境:
$ cat /run/flannel/subnet.env
FLANNEL_NETWORK=10.200.0.0/16
FLANNEL_SUBNET=10.200.50.1/24
FLANNEL_MTU=8951
FLANNEL_IPMASQ=false
ifconfig
说:
$ ifconfig
cbr0 Link encap:Ethernet HWaddr 0a:58:0a:c8:04:01
inet addr:10.200.4.1 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::d99:edff:fec6:9dd0/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:536 (536.0 B) TX bytes:648 (648.0 B)
docker0 Link encap:Ethernet HWaddr 02:42:a4:4b:44:dc
inet addr:10.200.50.1 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 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)
eth0 Link encap:Ethernet HWaddr 12:e7:81:c3:1e:58
inet addr:10.0.2.152 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe90::10e8:86ff:fec3:1e58/54 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:9001 Metric:1
RX packets:911006 errors:0 dropped:0 overruns:0 frame:0
TX packets:821093 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:725362580 (725.3 MB) TX bytes:155420170 (155.4 MB)
flannel.1 Link encap:Ethernet HWaddr 12:10:54:76:3e:c4
inet addr:10.200.50.0 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::1410:54ff:fe86:3ec4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:8951 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:11 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:27 errors:0 dropped:0 overruns:0 frame:0
TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1624 (1.6 KB) TX bytes:1624 (1.6 KB)
如何确保 pod 的 IP 地址来自 flannel 接口?
您可能需要检查您的 kubernetes 部署,以确保您没有使用任何网络插件,因为您正在使用 flannel。