Flannel容器网络模型及实现
2021-03-09 10:29:19 2 举报
Flannel容器网络模型及实现
作者其他创作
大纲/内容
flannel0(tun)
Flannel
FCS
ip route show:10.244.0.0 0.0.0.0 255.255.255.0 U cni010.244.1.0 172.16.130.140 255.255.255.0 UG eth110.244.2.0 172.16.130.164 255.255.255.0 UG eth1172.16.130.0 0.0.0.0 255.255.255.0 U eth1
POD-B
Route
可通过 arp -n 命令查看到 master 节点当中已经缓存了另外两个节点以及 VTEP 的 ARP 信息
Flanneld
flanneld对 packet 目标 IP 地址所属的网段信息查询其对应的下一跳主机 IP(容器子网 CIDR 和所属主机 IP 的映射保存在 etcd 中)
IP over UDP
veth
eth0(veth)
cni0(Bridge)10.244.1.1
bridge fdb show dev flannel.142:7f:69:c7:cd:37 dst 172.16.130.164 self permanent7a:2c:d0:7f:48:3f dst 172.16.130.140 self permanent
Flanneld
Node1
ETCD
VXLAN
source: 10.244.1.96dst: 10.244.2.194
eth0(veth)10.244.1.96
cni0(Bridge)
eth0172.16.130.140
Key & Value
OriginalL2 Frame
flannel1(vtep)
Kernel
ip route show:10.244.0.0 10.244.0.0 255.255.255.0 UG flannel110.244.1.0 0.0.0.0 255.255.255.0 U cni010.244.2.0 10.244.2.0 255.255.255.0 UG flannel1172.16.130.0 0.0.0.0 255.255.255.0 U eth1
eth0172.16.130.164
Flannel host-gw 通信示例
host ip172.16.130.164
Flannel VXLAN 通信示例
pod ip cird10.244.2.0/24
flanneld依据etcd的信息配置主机上的路由
VXLANHeader
监听 udp:8472
eth0(veth)10.244.2.194
POD-A
Flannel UDP 通信示例
cni0(Bridge)10.244.2.1
ip route show:0.0.0.0 10.244.1.1 0.0.0.0 UG 0 0 eth010.244.0.0 10.244.1.1 255.255.0.0 UG 0 0 eth010.244.1.0 0.0.0.0 255.255.255.0 U 0 0 eth0
arp -nAddress HWtype HWaddress Flags Iface10.244.2.0 ether 42:7f:69:c7:cd:37 CM flannel.110.244.1.0 ether 7a:2c:d0:7f:48:3f CM flannel.1172.16.130.140 ether fa:89:cf:03:e3:01 C eth1172.16.130.164 ether fa:88:2a:44:2b:01 C eth1
eth0
OuterIP
InnerIP
UDPHeader
Node2
VXLAN TUN
ip route show:10.244.0.0 0.0.0.0 255.255.0.0 UG 0 0 flannel010.244.1.0 10.244.1.1 255.255.255.0 UG 0 0 cni0172.16.130.0 0.0.0.0 255.255.255.0 U 0 0 eth1
IPHeader
Flannel网络模型
Flanneld :8285
ip route show:10.244.0.0 0.0.0.0 255.255.0.0 UG 0 0 flannel010.244.2.0 10.244.1.1 255.255.255.0 UG 0 0 cni0172.16.130.0 0.0.0.0 255.255.255.0 U 0 0 eth1
通过 bridge 命令查看节点上的 VXLAN 转发表(FDB entry),MAC 为对端 VTEP 设备即 flannel.1 的 MAC,IP 为 VTEP 对应的对外 IP,可以看到已经有两条转发表。
UDP
EthernetHeader
ip route show:10.244.0.0 172.16.130.244 255.255.255.0 UG eth110.244.1.0 172.16.130.140 255.255.255.0 UG eth110.244.2.0 0.0.0.0 255.255.255.0 U cni0172.16.130.0 0.0.0.0 255.255.255.0 U eth1
Playload
Packet
MAC
source: 172.16.130.140dst: 172.16.130.164
ip route show:10.244.0.0 10.244.0.0 255.255.255.0 UG flannel110.244.1.0 10.244.1.0 255.255.255.0 UG flannel110.244.2.0 0.0.0.0 255.255.255.0 UG cni0172.16.130.0 0.0.0.0 255.255.255.0 U eth1
0 条评论
下一页