合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
Flannel是一个网络规划服务,它的功能是让集群中的不同节点主机创建的Docker容器都具有全集群唯一的虚拟IP地址。 [DockOne技术分享(十八):一篇文章带你了解Flannel](http://dockone.io/article/618) 同etcd,下载可执行文件。 将可执行文件flanneld拷贝到/usr/bin/目录。 创建/usr/bin/flannel目录,并将dist目录下的mk-docker-opts.sh文件拷贝到/usr/bin/flannel/中。 [下载地址](https://github.com/coreos/flannel/releases?after=v0.6.2) ### 配置 --- #### 1. 创建配置目录和文件 ``` sudo vim /etc/default/flanneld.conf ``` ``` # Flanneld configuration options # etcd url location. Point this to the server where etcd runs FLANNEL_ETCD_ENDPOINTS="http://本机ip:2379" # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_PREFIX="/coreos.com/network" # Any additional options that you want to pass #FLANNEL_OPTIONS="" ``` 其中,FLANNEL_ETCD_PREFIX选项就是刚才配置的etcd网络。 #### 2. 创建systemd文件 ``` sudo vim /lib/systemd/system/flanneld.service ``` ``` [Unit] Description=Flanneld Documentation=https://github.com/coreos/flannel After=network.target After=etcd.service Before=docker.service [Service] User=root EnvironmentFile=/etc/default/flanneld.conf ExecStart=/usr/bin/flanneld \ -etcd-endpoints=${FLANNEL_ETCD_ENDPOINTS} \ -etcd-prefix=${FLANNEL_ETCD_PREFIX} \ $FLANNEL_OPTIONS ExecStartPost=/usr/bin/flannel/mk-docker-opts.sh -k DOCKER_OPTS -d /run/flannel/docker Restart=on-failure Type=notify LimitNOFILE=65536 [Install] WantedBy=multi-user.target RequiredBy=docker.service ``` #### 3. 启动服务 ``` sudo systemctl daemon-reload sudo systemctl enable flanneld sudo systemctl start flanneld ``` #### 4. 查看服务是否启动 ``` sudo systemctl status flanneld ``` #### 5. docker 安装(见docker安装教程) #### 6. 使flannel 作用docker网络 ``` sudo mkdir /lib/systemd/system/docker.service.d sudo vim /lib/systemd/system/docker.service.d/flannel.conf ``` ``` [Service] EnvironmentFile=-/run/flannel/docker ``` - 重启docker ``` sudo systemctl daemon-reload sudo systemctl restart docker ``` - 查看是否起作用 ``` sudo ps -ef | grep docker ``` ### 参考 [在Ubuntu16.04集群上手工部署Kubernetes](https://www.cnblogs.com/LinuxGo/p/5729788.html)