docker使用etcd,flannel实现容器跨主机通信

  • 环境
centos 192.168.3.65
centos 192.168.3.66
  • 全部关闭防火墙(关闭防火墙docker需要重启)
systemctl stop firewalld
  • 在192.168.3.65上 单节点部署etcd
yum install etcd
cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
vi /etc/etcd/etcd.conf

修改etcd.conf如下:
[Member]
ETCD_LISTEN_CLIENT_URLS="http://192.168.3.65:2379,http://127.0.0.1:2379"
[Clustering]
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.3.65:2379"
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"}'
  • 两台server安装flannel和配置
yum install -y flannel
cp /etc/sysconfig/flanneld /etc/sysconfig/flanneld.bak
vi /etc/sysconfig/flanneld

修改flanneld文件:
FLANNEL_ETCD_ENDPOINTS="http://192.168.3.65:2379"
systemctl start flanneld.service

你可能感兴趣的:(docker)