$ ip a ... 3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:4d:b8:7c:92 brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0 valid_lft forever preferred_lft forever ... 4: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default link/ether ee:61:5e:ff:69:8a brd ff:ff:ff:ff:ff:ff inet 10.10.0.0/32 scope global flannel.1 valid_lft forever preferred_lft forever inet6 fe80::ec61:5eff:feff:698a/64 scope link valid_lft forever preferred_lft forever ... 5: cni0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default qlen 1000 link/ether 16:4c:b3:10:4b:a2 brd ff:ff:ff:ff:ff:ff inet 10.10.0.1/24 brd 10.10.0.255 scope global cni0 valid_lft forever preferred_lft forever inet6 fe80::144c:b3ff:fe10:4ba2/64 scope link valid_lft forever preferred_lft forever ... 63: veth25155c69@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master cni0 state UP group default link/ether 66:a2:8d:4c:99:f8 brd ff:ff:ff:ff:ff:ff link-netnsid 3 inet6 fe80::64a2:8dff:fe4c:99f8/64 scope link valid_lft forever preferred_lft forever
$ brctl show bridge name bridge id STP enabled interfaces cni0 8000.164cb3104ba2 no veth25155c69 veth2ff698b2 vethcd663fc5 vethfb59328d docker0 8000.02424db87c92 no
另一个本机的 Pod
1 2 3 4 5 6 7 8 9
$ k exec nginx-deploy-5db48f768c-vv6dd -- ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: eth0@if62: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1450 qdisc noqueue state UP link/ether 22:9c:7e:84:c7:7c brd ff:ff:ff:ff:ff:ff inet 10.10.0.18/24 brd 10.10.0.255 scope global eth0 valid_lft forever preferred_lft forever
1 2 3 4 5 6 7
$ ip a ... 62: vethfb59328d@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master cni0 state UP group default link/ether be:83:0c:6c:00:22 brd ff:ff:ff:ff:ff:ff link-netnsid 2 inet6 fe80::bc83:cff:fe6c:22/64 scope link valid_lft forever preferred_lft forever ...
vethfb59328d 和 veth25155c69 都在 cni0 上,本机上的 Pod 可以直接通信
跨主机的网络,关键点在于 Node 的路由表
1 2 3 4 5 6 7 8 9
$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default _gateway 0.0.0.0 UG 100 0 0 ens160 10.10.0.0 0.0.0.0 255.255.255.0 U 0 0 0 cni0 10.10.1.0 10.10.1.0 255.255.255.0 UG 0 0 0 flannel.1 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 192.168.191.0 0.0.0.0 255.255.255.0 U 100 0 0 ens160 _gateway 0.0.0.0 255.255.255.255 UH 100 0 0 ens160