部署环境说明
主机名 | IP | 操作系统 |
node201 | 10.0.0.201 | centos 7.3 64位 |
node202 | 10.0.0.202 | centos 7.3 64位 |
node203 | 10.0.0.203 | centos 7.3 64位 |
前提条件:已安装etcd
配置etcd
etcdctl mkdir /kube-centos/network
etcdctl mk /kube-centos/network/config "{ \"Network\": \"172.30.0.0/16\", \"SubnetLen\": 24, \"Backend\": { \"Type\": \"vxlan\" } }"
以下操作需要在3个节点都执行。
安装flannel
yum install flannel
编辑配置文件
vim /etc/sysconfig/flanneld
# Flanneld configuration options
# etcd url location. Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://10.0.0.201:2379,http://10.0.0.202:2379,http://10.0.0.203:2379"
# etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/kube-centos/network"
# Any additional options that you want to pass
#FLANNEL_OPTIONS=""
运行flannel
systemctl enable flanneld
systemctl start flanneld
flanneld服务会通过执行脚本mk-docker-opts.sh在目录/run/flannel下面生成两个文件。
node201节点/run/flannel/docker
node201节点/run/flannel/subnet.env
/usr/lib/systemd/system/docker.service.d/flannel.conf指向/run/flannel/docker
最终结果
在节点node202做同样的操作,最终结果如下
在节点node203做同样的操作,最终结果如下
查看etcd
--结束--