猫言猫语

严以律己·宽以待人·自强不息·知行合一

在 CentOS 7.3 上安装 Docker + Flannel

| 在 CentOS 7.3 上安装 Docker + Flannel已关闭评论

节点信息

本次安装一共使用三个节点:

node01: eth1 192.168.33.101
node02: eth1 192.168.33.102
node03: eth1 192.168.33.103

Node 1

Node 1 节点上安装 etcd 服务:

yum install -y etcd
# vi /etc/etcd/etcd.conf

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.33.101:2379"
systemctl enable etcd
systemctl start etcd
etcdctl set /atomic.io/network/config '{ "Network": "172.17.0.0/16" }'

Node 2

Node 2 节点安装 Docker 与 Flannel

yum install -y docker flannel
# vi /etc/sysconfig/flanneld

FLANNEL_ETCD_ENDPOINTS="http://192.168.33.101:2379"
FLANNEL_OPTIONS="-iface=eth1"
systemctl enable docker flanneld
systemctl start docker flanneld

Node 3

Node 3 节点安装 Docker 与 Flannel

yum install -y docker flannel
# vi /etc/sysconfig/flanneld

FLANNEL_ETCD_ENDPOINTS="http://192.168.33.101:2379"
FLANNEL_OPTIONS="-iface=eth1"
systemctl enable docker flanneld
systemctl start docker flanneld

网络测试

在 Node 2 与 Node 3 上分别启动 2 个 centos 的容器:

docker run -it centos bash

然后再分别获取他们的 IP 地址

hostname -I

ping 一下,证明两个容器是可以互通的

[root@c646f7c8b6c2 /]# ping 172.17.77.3 
PING 172.17.77.3 (172.17.77.3) 56(84) bytes of data.
64 bytes from 172.17.77.3: icmp_seq=1 ttl=60 time=2.23 ms
64 bytes from 172.17.77.3: icmp_seq=2 ttl=60 time=0.760 ms
[root@06452f2322d4 bin]# ping 172.17.84.3
PING 172.17.84.3 (172.17.84.3) 56(84) bytes of data.
64 bytes from 172.17.84.3: icmp_seq=1 ttl=60 time=1.32 ms
64 bytes from 172.17.84.3: icmp_seq=2 ttl=60 time=0.747 ms

评论已关闭。