2019-04-11

三角形發表於2019-04-11

host1

 1 root@host1:~# calicoctl node run --ip 10.12.31.22 --config=/etc/calico/calicoctl.cfg
 2 Running command to load modules: modprobe -a xt_set ip6_tables
 3 Enabling IPv4 forwarding
 4 Enabling IPv6 forwarding
 5 Increasing conntrack limit
 6 Removing old calico-node container (if running).
 7 Running the following command to start calico-node:
 8 
 9 docker run --net=host --privileged --name=calico-node -d --restart=always -e NODENAME=host1 -e CALICO_NETWORKING_BACKEND=bird -e IP=10.12.31.22 -e ETCD_AUTHORITY= -e ETCD_SCHEME= -e NO_DEFAULT_POOLS= -e CALICO_LIBNETWORK_ENABLED=true -e CALICO_LIBNETWORK_IFPREFIX=cali -e ETCD_ENDPOINTS=http://10.12.31.21:2379 -v /var/log/calico:/var/log/calico -v /run/docker/plugins:/run/docker/plugins -v /var/run/docker.sock:/var/run/docker.sock -v /var/run/calico:/var/run/calico -v /lib/modules:/lib/modules calico/node:v1.0.2
10 
11 Image may take a short time to download if it is not available locally.
12 Container started, checking progress logs.
13 Waiting for etcd connection...
14 Using IPv4 address from IP environment: 10.12.31.22
15 No IPv6 address configured
16 Using global AS number
17 WARNING: Hostname 'host1' is already in use with IP address 10.32.0.3. Calico requires each compute host to have a unique hostname. If this is your first time running the Calico node on this host, ensure that another host is not already using the same hostname.
18 Calico node name:  host1
19 CALICO_LIBNETWORK_ENABLED is true - start libnetwork service
20 Calico node started successfully
21 root@host1:~# docker ps -a
22 CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS               NAMES
23 5185054c463c        calico/node:v1.0.2   "start_runit"       18 seconds ago      Up 18 seconds                           calico-node
24 root@host1:~# docker network create --driver calico --ipam-driver calico-ipam cal_net1
25 7f79b95822b8154a7294c97fc75b4406a1df6c87098369fd058952f7a0fffde5
26 root@host1:~# docker network ls
27 NETWORK ID          NAME                DRIVER              SCOPE
28 aed7d2f6a552        bridge              bridge              local
29 7f79b95822b8        cal_net1            calico              global
30 8de65d3db216        docker_gwbridge     bridge              local
31 81e05e6b8562        host                host                local
32 85119df777e1        none                null                local
33 root@host1:~# ip r
34 default via 10.12.28.6 dev ens192 onlink 
35 10.2.9.0/24 dev docker0  proto kernel  scope link  src 10.2.9.1 linkdown 
36 10.12.28.0/22 dev ens192  proto kernel  scope link  src 10.12.31.22 
37 172.18.0.0/16 dev docker_gwbridge  proto kernel  scope link  src 172.18.0.1 linkdown 
38 blackhole 192.168.119.0/26  proto bird 
39 192.168.183.64/26 via 10.12.31.23 dev ens192  proto bird 

 

host2

 1 root@host2:~# calicoctl node run --ip 10.12.31.23 --config=/etc/calico/calicoctl.cfg
 2 Running command to load modules: modprobe -a xt_set ip6_tables
 3 Enabling IPv4 forwarding
 4 Enabling IPv6 forwarding
 5 Increasing conntrack limit
 6 Removing old calico-node container (if running).
 7 Running the following command to start calico-node:
 8 
 9 docker run --net=host --privileged --name=calico-node -d --restart=always -e NO_DEFAULT_POOLS= -e CALICO_LIBNETWORK_IFPREFIX=cali -e ETCD_ENDPOINTS=http://10.12.31.21:2379 -e ETCD_SCHEME= -e ETCD_AUTHORITY= -e NODENAME=host2 -e CALICO_NETWORKING_BACKEND=bird -e CALICO_LIBNETWORK_ENABLED=true -e IP=10.12.31.23 -v /var/run/calico:/var/run/calico -v /lib/modules:/lib/modules -v /var/log/calico:/var/log/calico -v /run/docker/plugins:/run/docker/plugins -v /var/run/docker.sock:/var/run/docker.sock calico/node:v1.0.2
10 
11 Image may take a short time to download if it is not available locally.
12 Container started, checking progress logs.
13 Waiting for etcd connection...
14 Using IPv4 address from IP environment: 10.12.31.23
15 No IPv6 address configured
16 Using global AS number
17 Calico node name:  host2
18 CALICO_LIBNETWORK_ENABLED is true - start libnetwork service
19 Calico node started successfully
20 root@host2:~# docker ps -a
21 CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS               NAMES
22 ef25807d2919        calico/node:v1.0.2   "start_runit"       6 seconds ago       Up 5 seconds                            calico-node
23 root@host2:~# docker network ls
24 NETWORK ID          NAME                DRIVER              SCOPE
25 0a4f8974ea62        bridge              bridge              local
26 7f79b95822b8        cal_net1            calico              global
27 a22c1957a61e        docker_gwbridge     bridge              local
28 b8f586751d99        host                host                local
29 00b0a10c56b9        none                null                local
30 root@host2:~# ip r
31 default via 10.12.28.6 dev ens192 onlink 
32 10.2.52.0/24 dev docker0  proto kernel  scope link  src 10.2.52.1 linkdown 
33 10.12.28.0/22 dev ens192  proto kernel  scope link  src 10.12.31.23 
34 172.18.0.0/16 dev docker_gwbridge  proto kernel  scope link  src 172.18.0.1 linkdown 
35 192.168.119.0/26 via 10.12.31.22 dev ens192  proto bird 
36 blackhole 192.168.183.64/26  proto bird 

 

 1 root@host1:~# docker run -itd --name bbox1 --network cal_net1 busybox
 2 0a0ff37b70e6f095a04b433a5017e312b7704d98272854938ac52f0392895aac
 3 root@host1:~# ip r
 4 default via 10.12.28.6 dev ens192 onlink 
 5 10.2.9.0/24 dev docker0  proto kernel  scope link  src 10.2.9.1 linkdown 
 6 10.12.28.0/22 dev ens192  proto kernel  scope link  src 10.12.31.22 
 7 172.18.0.0/16 dev docker_gwbridge  proto kernel  scope link  src 172.18.0.1 linkdown 
 8 blackhole 192.168.119.0/26  proto bird 
 9 192.168.119.5 dev calidf88ad6b640  scope link 
10 192.168.183.64/26 via 10.12.31.23 dev ens192  proto bird 
11 
12 
13 
14 root@host2:~# docker run -itd --name bbox2 --network cal_net1 busybox
15 7e2a70e903e30c957c4236004b10cb0ccf31e5af6e0f9a689874c3578fdd2ee4
16 root@host2:~# docker exec bbox2 ping -c 2 bbox1
17 PING bbox1 (192.168.119.5): 56 data bytes
18 64 bytes from 192.168.119.5: seq=0 ttl=62 time=0.453 ms
19 64 bytes from 192.168.119.5: seq=1 ttl=62 time=0.333 ms
20 
21 --- bbox1 ping statistics ---
22 2 packets transmitted, 2 packets received, 0% packet loss
23 round-trip min/avg/max = 0.333/0.393/0.453 ms
24 root@host2:~# ip r
25 default via 10.12.28.6 dev ens192 onlink 
26 10.2.52.0/24 dev docker0  proto kernel  scope link  src 10.2.52.1 linkdown 
27 10.12.28.0/22 dev ens192  proto kernel  scope link  src 10.12.31.23 
28 172.18.0.0/16 dev docker_gwbridge  proto kernel  scope link  src 172.18.0.1 linkdown 
29 192.168.119.0/26 via 10.12.31.22 dev ens192  proto bird 
30 blackhole 192.168.183.64/26  proto bird 
31 192.168.183.69 dev calic68bb32cba4  scope link