1. 程式人生 > >k8s部署flannel網絡

k8s部署flannel網絡

docker flannel k8s

1 yum安裝flannel包: yum install flannel -y

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 ~]#

k8s部署flannel網絡