[root@localhost ~]# etcdctl member list 8e92f64982d9786c: name=node2 peerURLs=http://192.168.15.134:2380 clientURLs=http://192.168.15.134:2379 isLeader=false d3e45f62ae9d5a52: name=node1 peerURLs=http://192.168.15.133:2380 clientURLs=http://192.168.15.133:2379 isLeader=true [root@localhost ~]# etcdctl cluster-health member 8e92f64982d9786c is healthy: got healthy result from http://192.168.15.134:2379 member d3e45f62ae9d5a52 is healthy: got healthy result from http://192.168.15.133:2379 cluster is healthy
[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2d9f4e006b37 quay.io/calico/node:v2.6.10 "start_runit" About an hour ago Up About an hour calico-node
[root@localhost ~]# calicoctl node status Calico process is running.
IPv4 BGP status +----------------+-------------------+-------+----------+-------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +----------------+-------------------+-------+----------+-------------+ | 192.168.15.134 | node-to-node mesh | up | 12:24:19 | Established | +----------------+-------------------+-------+----------+-------------+
IPv6 BGP status No IPv6 peers found.
node2
1 2 3 4 5 6 7 8 9 10 11 12
[root@localhost ~]# calicoctl node status Calico process is running.
IPv4 BGP status +----------------+-------------------+-------+----------+-------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +----------------+-------------------+-------+----------+-------------+ | 192.168.15.133 | node-to-node mesh | up | 12:24:21 | Established | +----------------+-------------------+-------+----------+-------------+
[root@localhost ~]# docker network ls NETWORK ID NAME DRIVER SCOPE dd3ae1400375 bridge bridge local b87973f6e3da host host local aaea1c24a3d6 net1 calico global efebcca875b3 net2 calico global 0fd941dfe66b none null local
在node1和node2上创建容器来测试下容器网络的连通性
下载busybox工具,方便测试使用
1
[root@localhost ~]# docker pull busybox
node1
1 2
[root@localhost ~]# docker run --net net1 --name workload-A -tid busybox [root@localhost ~]# docker run --net net2 --name workload-B -tid busybox
node2
1
[root@localhost ~]# docker run --net net1 --name workload-E -tid busybox
同一网络内的容器(即使不在同一节点主机上)可以使用容器名来访问
node1
1 2 3 4 5 6 7 8 9 10
[root@localhost ~]# docker exec workload-A ping -c 4 workload-E.net1 PING workload-E.net1 (10.20.0.1): 56 data bytes 64 bytes from 10.20.0.1: seq=0 ttl=62 time=0.811 ms 64 bytes from 10.20.0.1: seq=1 ttl=62 time=0.220 ms 64 bytes from 10.20.0.1: seq=2 ttl=62 time=0.157 ms 64 bytes from 10.20.0.1: seq=3 ttl=62 time=0.231 ms
--- workload-E.net1 ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 0.157/0.354/0.811 ms
node2
1 2 3 4 5 6 7 8 9 10
[root@localhost ~]# docker exec workload-E ping -c 4 workload-A.net1 PING workload-A.net1 (10.20.0.129): 56 data bytes 64 bytes from 10.20.0.129: seq=0 ttl=62 time=1.964 ms 64 bytes from 10.20.0.129: seq=1 ttl=62 time=1.152 ms 64 bytes from 10.20.0.129: seq=2 ttl=62 time=0.521 ms 64 bytes from 10.20.0.129: seq=3 ttl=62 time=0.503 ms
--- workload-A.net1 ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 0.503/1.035/1.964 ms