这是Flannel官网给出的网络架构图
这是通过自己的理解画的逻辑结构图
查看bridge
[root@node01 ~]# brctl show
bridge name bridge id STP enabled interfaces
cni0 .0a580af40001 no veth34bdd66f
veth374f9b6c
vethfe4aad1b
docker0 .0242ec6d0fef no
查看netns (需要先执行 ln -s /var/run/docker/netns /var/run/netns)
[root@node01 ~]# ip netns list
2ae7b96d0db6 (id: )
21684eef26a3 (id: )
6c568775f2d9 (id: )
default
查看网络接口
[root@node01 netns]# ip -d link show
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN mode DEFAULT qlen
link/loopback ::::: brd ::::: promiscuity addrgenmode eui64
: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP mode DEFAULT qlen
link/ether :0c::3a:: brd ff:ff:ff:ff:ff:ff promiscuity addrgenmode eui64
: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu qdisc noqueue state DOWN mode DEFAULT
link/ether ::ec:6d:0f:ef brd ff:ff:ff:ff:ff:ff promiscuity
bridge forward_delay hello_time max_age ageing_time stp_state priority vlan_filtering vlan_protocol .1Q bridge_id 8000.2::ec:6d:f:ef designated_root 8000.2::ec:6d:f:ef root_port root_path_cost topology_change topology_change_detected hello_timer 0.00 tcn_timer 0.00 topology_change_timer 0.00 gc_timer 241.95 vlan_default_pvid group_fwd_mask group_address ::c2::: mcast_snooping mcast_router mcast_query_use_ifaddr mcast_querier mcast_hash_elasticity mcast_hash_max mcast_last_member_count mcast_startup_query_count mcast_last_member_interval mcast_membership_interval mcast_querier_interval mcast_query_interval mcast_query_response_interval mcast_startup_query_interval addrgenmode eui64
: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN mode DEFAULT
link/ether 3e:bb:9b::a4: brd ff:ff:ff:ff:ff:ff promiscuity
vxlan id 1 local 172.16.65.181 dev ens33 srcport dstport nolearning ageing addrgenmode eui64
: cni0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc noqueue state UP mode DEFAULT qlen
link/ether 0a::0a:f4:: brd ff:ff:ff:ff:ff:ff promiscuity
bridge forward_delay hello_time max_age ageing_time stp_state priority vlan_filtering vlan_protocol .1Q bridge_id .a::a:f4:: designated_root .a::a:f4:: root_port root_path_cost topology_change topology_change_detected hello_timer 0.00 tcn_timer 0.00 topology_change_timer 0.00 gc_timer 27.93 vlan_default_pvid group_fwd_mask group_address ::c2::: mcast_snooping mcast_router mcast_query_use_ifaddr mcast_querier mcast_hash_elasticity mcast_hash_max mcast_last_member_count mcast_startup_query_count mcast_last_member_interval mcast_membership_interval mcast_querier_interval mcast_query_interval mcast_query_response_interval mcast_startup_query_interval addrgenmode eui64
: vethfe4aad1b@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc noqueue master cni0 state UP mode DEFAULT
link/ether ::8d:0d:: brd ff:ff:ff:ff:ff:ff link-netnsid promiscuity
veth
bridge_slave state forwarding priority cost hairpin on guard off root_block off fastleave off learning on flood on port_id 0x8001 port_no 0x1 designated_port designated_cost designated_bridge .a::a:f4:: designated_root .a::a:f4:: hold_timer 0.00 message_age_timer 0.00 forward_delay_timer 0.00 topology_change_ack config_pending proxy_arp off proxy_arp_wifi off mcast_router mcast_fast_leave off mcast_flood on addrgenmode eui64
: veth374f9b6c@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc noqueue master cni0 state UP mode DEFAULT
link/ether 5a::::b3: brd ff:ff:ff:ff:ff:ff link-netnsid promiscuity
veth
bridge_slave state forwarding priority cost hairpin on guard off root_block off fastleave off learning on flood on port_id 0x8002 port_no 0x2 designated_port designated_cost designated_bridge .a::a:f4:: designated_root .a::a:f4:: hold_timer 0.00 message_age_timer 0.00 forward_delay_timer 0.00 topology_change_ack config_pending proxy_arp off proxy_arp_wifi off mcast_router mcast_fast_leave off mcast_flood on addrgenmode eui64
: veth34bdd66f@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc noqueue master cni0 state UP mode DEFAULT
link/ether d6:f9:c1:4d:4c:af brd ff:ff:ff:ff:ff:ff link-netnsid promiscuity
veth
bridge_slave state forwarding priority cost hairpin on guard off root_block off fastleave off learning on flood on port_id 0x8003 port_no 0x3 designated_port designated_cost designated_bridge .a::a:f4:: designated_root .a::a:f4:: hold_timer 0.00 message_age_timer 0.00 forward_delay_timer 0.00 topology_change_ack config_pending proxy_arp off proxy_arp_wifi off mcast_router mcast_fast_leave off mcast_flood on addrgenmode eui64
查看路由
[root@node01 netns]# ip route
default via 172.16.65.2 dev ens33 proto static metric
10.244.0.0/24 dev cni0 proto kernel scope link src 10.244.0.1
10.244.1.0/24 via 10.244.1.0 dev flannel.1 onlink
10.244.2.0/24 via 10.244.2.0 dev flannel.1 onlink
172.16.65.0/ dev ens33 proto kernel scope link src 172.16.65.181 metric
172.17.0.0/ dev docker0 proto kernel scope link src 172.17.0.1
参考文章:https://tonybai.com/2017/01/17/understanding-flannel-network-for-kubernetes/