部署环境:
CentOS Linux release 7.2 64位
10.10.0.103 node01
10.10.0.49 node02
安装过程:
# yum install flannel
# tar zxf flannel-v0.8.0-linux-amd64_.tar.gz
# cp flanneld /usr/bin/
# cp mk-docker-opts.sh /usr/bin/
编辑服务配置文件:
#cat /usr/lib/systemd/system/flanneld.service [Unit] Description=flanneld overlay address etcd agent After=network.target Before=docker.service [Service] Type=notify EnvironmentFile=/etc/sysconfig/flannel ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD} $FLANNEL_OPTIONS [Install] RequiredBy=docker.service WantedBy=multi-user.target
编辑配置文件:
#cat /etc/sysconfig/flannel FLANNEL_ETCD="http://10.10.0.103:2379,http://10.10.0.49:2379" FLANNEL_ETCD_KEY="/coreos.com/network"
在etcd库中添加一条网络配置信息,flannel用来分配docker的虚拟ip地址段:
# etcdctl set /coreos.com/network/config
# etcdctl get /coreos.com/network/config
{ "Network": "10.1.0.0/16" }
# systemctl start flanneld
# mk-docker-ops.sh -i
# source /run/flannel/subnet.env
# ifconfig docker0 ${FLANNEL_SUBMENT}
#ifconfig 查看docker网卡ip
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.1.8.1 netmask 255.255.255.0 broadcast 10.1.8.255 ether 02:42:bf:cb:f1:ff txqueuelen 0 (Ethernet) RX packets 40369 bytes 8671191 (8.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 40663 bytes 3818695 (3.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.10.0.103 netmask 255.255.0.0 broadcast 10.10.255.255 ether 00:16:3e:08:93:f7 txqueuelen 1000 (Ethernet) RX packets 2033352 bytes 695497718 (663.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1378035 bytes 2166169069 (2.0 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 flannel0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1472 inet 10.1.8.0 netmask 255.255.0.0 destination 10.1.8.0 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC) RX packets 6 bytes 504 (504.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6 bytes 504 (504.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
另一个节点同样重复以上安装步骤。
时间: 2024-10-25 10:56:04