Etcd安装
生产环境建议使用集群方式
wget https://github.com/etcd-io/etcd/releases/download/v3.3.15/etcd-v3.3.15-linux-amd64.tar.gz tar -zxvf etcd-v3.3.15-linux-amd64.tar.gz && cd etcd-v3.3.15-linux-amd64 mv etcd* /usr/local/bin/ mkdir /var/lib/etcd/
cat /usr/lib/systemd/system/etcd.service [Unit] Description=Etcd Server After=netNork.target After=network-online.target Wants=network-online.target [Service] Type=notify ExecStart=/usr/local/bin/etcd \ --name=etcd \ --data-dir=/var/lib/etcd/default.etcd \ --listen-peer-urls=http://192.168.3.155:2380 \ --listen-client-urls=http://192.168.3.155:2379,http://127.0.0.1:2379 \ --advertise-client-urls=http://192.168.3.155:2379 \ --initial-advertise-peer-urls=http://192.168.3.155:2380 \ --initial-cluster=etcd=http://192.168.3.155:2380 \ --initial-cluster-token=etcd-cluster \ --initial-cluster-state=new Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target
systemctl start etcd
安装flannel
yum -y install flannel
cat /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.3.155:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
注册flannel的网络配置到etcd
3.3.15版本默认api为V3,flannel支持V2版本
ETCDCTL_API=2 etcdctl --endpoint=http://192.168.3.155:2379 set /atomic.io/network/config '{"Network":"172.17.0.0/16", "SubnetMin": "172.17.1.0", "SubnetMax": "172.17.254.0", "Backend": {"Type": "vxlan"}}'
systemctl start flannel
Flannel启动后,将从etcd获取网络配置信息
划分子网并在etcd中注册
将网络配置写入/run/flannel/subnet.env,并通过脚本生成/run/flannel/docker文件
查看etcd注册信息
修改docker启动参数
cat /usr/lib/systemd/system/docker.service
EnvironmentFile=/var/run/flannel/docker
ExecStart=/usr/bin/dockerd $DOCKER_NETWORK_OPTIONS
systemctl daemon-reload && systemctl restart docker
查看IP
参考:
https://coreos.com/flannel/docs/latest/running.html#docker-integration
https://coreos.com/flannel/docs/latest/flannel-config.html
https://github.com/etcd-io/etcd
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。