Etcd installation
Production environment is recommended to use the cluster approach
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
Installation flannel
yum -y install flannel
cat /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.3.155:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
Registration flannel network configuration to etcd
The default version is 3.3.15 api V3, flannel support V2 version
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
After Flannel start, obtain network configuration information from etcd
Subnetting and registered in etcd
The network configuration write /run/flannel/subnet.env, and generates / run / flannel / docker script files
View etcd Registration Information
Modify the startup parameters 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
Check IP
reference:
https://coreos.com/flannel/docs/latest/running.html#docker-integration