1 yum安裝flannel包: yum install flannel -ydocker
2 編輯配置文件
vim /etc/sysconfig/flanneldvim
FLANNEL_ETCD_ENDPOINTS="http://192.168.233.130:2379"網絡
FLANNEL_ETCD_PREFIX="/coreos.com/network"ide
#FLANNEL_OPTIONS=""3d
3 flannel網絡依賴etcd存儲,啓動flanneld服務前需在etcd存儲裏添加配置:
etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }'blog
4 啓動flanneld服務前必須先關閉docker服務:
systemctl stop docker
systemctl start flanneld部署
5 flanneld服務會經過執行腳本mk-docker-opts.sh在目錄/run/flannel下面生成兩個文件。get
/run/flannel/docker
/run/flannel/subnet.env
/usr/lib/systemd/system/docker.service.d/flannel.conf指向/run/flannel/dockerit
6 systemctl start docker:
ast
7 查看etcd:[root@master ~]# etcdctl get /coreos.com/network/subnets/10.1.95.0-24{"PublicIP":"192.168.233.128"}[root@master ~]# etcdctl get /coreos.com/network/subnets/10.1.39.0-24{"PublicIP":"192.168.233.129"}[root@master ~]# etcdctl get /coreos.com/network/config{ "Network": "10.1.0.0/16" }[root@master ~]#