参考文档 https://coreos.com/flannel/docs/latest/
1. 基础环境(服务器IP:172.17.0.51,52,53)
a.系统版本 CentOS Linux release 7.6.1810 (Core)
b.flannel版本 0.7.1
c.修改主机名 hostnamectl --static set-hostname node51,修改 /etc/hosts
2. 安装flannel
yum install -y flannel
3. 配置flannel
a. flannel配置文件/etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="https://172.17.0.51:2379,https://172.17.0.52:2379,https://172.17.0.53:2379"
FLANNEL_ETCD_PREFIX="/xxx.com/network"
FLANNEL_OPTIONS="-etcd-cafile=/etc/etcd/ca.pem -etcd-certfile=/etc/etcd/server.pem -etcd-keyfile=/etc/etcd/server-key.pem"
b. /usr/lib/systemd/system/flanneld.service
去掉After=etcd.service
确认Before=docker.servic
4. 启动配置
a. 向etcd注册网段(其中一台etcd服务器操作即可)
etcdctl --ca-file=/etc/etcd/ca.pem --cert-file=/etc/etcd/server.pem --key-file=/etc/etcd/server-key.pem --endpoints="https://172.17.0.51:2379" set /xxx.com/network/config '{ "Network": "10.88.0.0/16"}'
b. 添加快速启动
systemctl enable flanneld && systemctl daemon-reload
c. 启动(flannel要关闭docker,覆盖docker网桥)
systemctl start flanneld && systemctl start docker
d. 查看节点获得的IP
[root@node51 docker]# ip a |grep inet
inet 127.0.0.1/8 scope host lo
inet 172.17.0.51/24 brd 172.17.0.255 scope global eth0
inet 10.88.16.0/16 scope global flannel0
inet 10.88.16.1/24 brd 10.88.16.255 scope global docker0