美文网首页挨踢(IT)
Docker flannel网络搭建(跨主机通信)

Docker flannel网络搭建(跨主机通信)

作者: SkTj | 来源:发表于2019-10-28 14:28 被阅读0次

    flannel 没有VLAN划分

    1、设置hosts (所有主机)
    vi /etc/hosts
    192.168.118.77 k8smaster
    192.168.118.72 k8snode01

    service firewalld stop

    关闭防火墙后要重启docker

    2、开启2379和4001 (所有主机)
    firewall-cmd --add-port=2379/tcp --permanent
    firewall-cmd --add-port=2380/tcp --permanent
    firewall-cmd --add-port=4001/tcp --permanent
    firewall-cmd --reload

    3、主机安装etcd
    yum install etcd -y
    cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak

    vi /etc/etcd/etcd.conf

    [Member]

    ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379,http://0.0.0.0:4001"

    [Clustering]

    ETCD_ADVERTISE_CLIENT_URLS="http://192.168.118.77:2379,http://192.168.118.77:4001"

    systemctl start etcd

    设置etcd的网络

    etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16", "SubnetMin": "172.17.1.0", "SubnetMax": "172.17.254.0"}'

    etcdctl -C http://192.168.118.77:4001 cluster-health

    4、安装flannel(所有主机)
    yum install -y flannel
    cp /etc/sysconfig/flanneld /etc/sysconfig/flanneld.bak

    vi /etc/sysconfig/flanneld
    FLANNEL_ETCD_ENDPOINTS="http://192.168.118.77:2379"

    systemctl enable flanneld.service
    systemctl start flanneld.service
    systemctl restart docker

    5、设置DOCKER默认网络,(所有主机,每台的子网不一样,分别设置)
    cat /run/flannel/subnet.env
    FLANNEL_NETWORK=172.17.0.0/16
    FLANNEL_SUBNET=172.17.82.1/24
    FLANNEL_MTU=1472
    FLANNEL_IPMASQ=false

    vi /usr/lib/systemd/system/docker.service
    ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --bip=172.17.50.1/24 --mtu=1472

    systemctl daemon-reload
    systemctl restart docker

    相关文章

      网友评论

        本文标题:Docker flannel网络搭建(跨主机通信)

        本文链接:https://www.haomeiwen.com/subject/taipvctx.html