2 编辑配置文件
vim /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.233.130:2379"
FLANNEL_ETCD_PREFIX="/coreos.com/network"
#FLANNEL_OPTIONS=""
3 flannel网络依赖etcd存储,启动flanneld服务前需在etcd存储里添加配置:
etcdctl set /coreos.com/network/config ‘{ "Network": "10.1.0.0/16" }‘
4 启动flanneld服务前必须先关闭docker服务:
systemctl stop docker
systemctl start flanneld
5 flanneld服务会通过执行脚本mk-docker-opts.sh在目录/run/flannel下面生成两个文件。
/run/flannel/docker
/run/flannel/subnet.env
/usr/lib/systemd/system/docker.service.d/flannel.conf指向/run/flannel/docker
6 systemctl start docker:
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 ~]#
原文地址:http://blog.51cto.com/as007012/2084519