flannel+docker环境部署,无坑
作者:互联网
1.关闭防火墙:
systemctl stop firewalld && systemctl disable firewalld
2.etcd安装
rm -rf /tmp/etcd-data.tmp && mkdir -p /tmp/etcd-data.tmp && \
docker run -d \
--restart=always \
-p 2379:2379 \
-p 2380:2380 \
--mount type=bind,source=/tmp/etcd-data.tmp,destination=/etcd-data \
--name etcd-gcr-v3.3.13 \
gcr.io/etcd-development/etcd:v3.3.13 \
/usr/local/bin/etcd \
--name s1 \
--data-dir /etcd-data \
--listen-client-urls http://0.0.0.0:2379 \
--advertise-client-urls http://0.0.0.0:2379 \
--listen-peer-urls http://0.0.0.0:2380 \
--initial-advertise-peer-urls http://0.0.0.0:2380 \
--initial-cluster s1=http://0.0.0.0:2380 \
--initial-cluster-token tkn \
--initial-cluster-state new
或者
yum -y install etcd
修改/etc/etcd/etcd.conf 中的IP为 0.0.0.0
systemctl start etcd && systemctl enable etcd
验证etcd状态:
ETCDCTL_API=3 /usr/local/bin/etcdctl endpoint health
3.创建FLANNEL_ETCD_PREFIX,与/etc/sysconfig/flanneld中的FLANNEL_ETCD_PREFIX对应一致,如:
FLANNEL_ETCD_PREFIX="/atomic.io/network"
etcdctl mk /atomic.io/network/config '{"Network":"172.11.0.0/16", "SubnetMin": "172.11.1.0", "SubnetMax": "172.11.254.0", "Backend":{"Type":"vxlan"}}'
4.安装flannel
yum -y install flannel
5.修改/etc/sysconfig/flanneld,填写etcd ip
FLANNEL_ETCD_ENDPOINTS="http://192.168.1.147:2379"
6.启动flannel
systemctl start flanneld && systemctl enable flanneld
7.安装docker,
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
配置/usr/lib/systemd/system/docker.service,在ExecStart后面加上:
$DOCKER_NETWORK_OPTIONS,如:
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 192.168.1.74:80 $DOCKER_NETWORK_OPTIONS
启动docker:
systemctl daemon-reload && systemctl restart docker
由于iptables规则问题可能出现docker0到docker网络不通,查看iptables规则
iptables -nvL
显示:
Chain FORWARD (policy DROP 3161 packets, 266K bytes)
修改iptables规则
iptables -P FORWARD ACCEPT
标签:tmp,0.0,systemctl,etcd,无坑,docker,data,flannel 来源: https://blog.csdn.net/lfxyan/article/details/90236319