替换flanneld 安装 Calico

  • Post author:
  • Post category:其他


    1. 替换flannel 需要确保当前无正在运行的Container
    2. 关闭flanneld服务
    3. iptables -F -t nat && iptables -F
    4. 修改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

      kv.certfile=



      /path/to/cert


      .pem \



      --cluster-store-opt

      kv.keyfile=



      /path/to/key


      .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)其中文件对应的路径。

    5. systemctl daemon-reload && systemctl restart docker
    6. 下载分发calicoctl文件版本1.6.x(查看附件)到每台机器
    7. docker pull calico/node:v2.6.11
    8. docker pull adiazmor/docker-ubuntu-with-ping (用于测试,有其他镜像代替也可以)

    9. 编写配置文件位于/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>

    10. calicoctl node run –node-image=calico/node:v2.6.11 –ip=<本机IP,如果是40g网络则对应17段的ip>

    11. docker network create –driver calico –ipam-driver calico-ipam calico-net1
    12. docker network create –driver calico –ipam-driver calico-ipam calico-net2
    13. 在任意几台机器上分别创建 docker run –rm -it –network calico-net1 adiazmor/docker-ubuntu-with-ping  /bin/bash
    14. 用 ip a 查看当前ip 然后分别去ping其他同样加入了calico-net1  的ip 应该是可以ping通的
    15. 在任意几台机器上分别创建 docker run –rm -it –network calico-net2 adiazmor/docker-ubuntu-with-ping  /bin/bash
    16. 同样在calico-net2中的Container可以ping通,但是ping不通在calico-net1中的container

转载于:https://www.cnblogs.com/xuchenCN/p/11381735.html