-
- 替換flannel 需要確保當前無正在運行的Container
- 關閉flanneld服務
- iptables -F -t nat && iptables -F
-
修改docker.service文件
修改原本的ExecStart 設置etcd的地址,線上應該是 181,182,183三台
#ExecStart=/usr/bin/dockerd --ip-masq=false --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}
ExecStart=
/usr/bin/dockerd
--cluster-store=etcd:
//
<etcdendpoint>:<etcdport> --cluster-store-opt kv.cacertfile=
/path/to/ca
.pem \
其中 --cluster-store-opt 中的ca, cert, key 文件查看當前機器flanneld.service文件中的配置,例如(-etcd-keyfile=/root/etcd_ssl/client-key.pem --etcd-certfile=/root/etcd_ssl/client.pem --etcd-cafile=/root/etcd_ssl/ca.pem)其中文件對應的路徑。
- systemctl daemon-reload && systemctl restart docker
- 下載分發calicoctl文件版本1.6.x(查看附件)到每台機器
- docker pull calico/node:v2.6.11
-
docker pull adiazmor/docker-ubuntu-with-ping (用於測試,有其他鏡像代替也可以)
-
編寫配置文件位於/etc/calico/calicoctl.cfg
apiVersion: v1
kind: calicoApiConfig
metadata:
spec:
etcdEndpoints: https:
//
<etcd_addr>:2379,https:
//
<etcd_addr>:2379,https:
//
<etcd_addr>:2379
etcdKeyFile: <path to key>
etcdCertFile: <path to cert>
etcdCACertFile: <path to ca>
-
calicoctl node run --node-image=calico/node:v2.6.11 --ip=<本機IP,如果是40g網絡則對應17段的ip>
- docker network create --driver calico --ipam-driver calico-ipam calico-net1
- docker network create --driver calico --ipam-driver calico-ipam calico-net2
- 在任意幾台機器上分別創建 docker run --rm -it --network calico-net1 adiazmor/docker-ubuntu-with-ping /bin/bash
- 用 ip a 查看當前ip 然后分別去ping其他同樣加入了calico-net1 的ip 應該是可以ping通的
- 在任意幾台機器上分別創建 docker run --rm -it --network calico-net2 adiazmor/docker-ubuntu-with-ping /bin/bash
- 同樣在calico-net2中的Container可以ping通,但是ping不通在calico-net1中的container