原理和架构图参考上一篇,这里只记录操作步骤。
etcd version: 3.2.11
kube version: 1.8.4
docker version: 17.03.2-ce
OS version: debian stretch
三个ETCD节点(contiv插件也要使用etcd,这里每个节点复用跑2个etcd实例)
192.168.5.84 etcd0,contiv0
192.168.5.85 etcd1,contiv1
192.168.2.77 etcd2,contiv2
两个lvs节点
192.168.2.56 master
192.168.2.57 backup
4个k8s节点(3个master,1个node)
192.168.5.62 master01
192.168.5.63 master02
192.168.5.107 master03
192.168.5.68 node
1、部署ETCD,由于这几个节点版本较低,所以没有使用systemd
a、部署k8s使用的etcd集群,直接使用etcd二进制文件启动即可,启动脚本如下:
# cat etcd-start.sh
#获取IP
localip=`ifconfig em2|grep -w inet| awk ‘{print $2}‘|awk -F: ‘{print $2}‘`
pubip=0.0.0.0
#启动服务
etcd --name etcd0 -data-dir /var/lib/etcd --initial-advertise-peer-urls http://${localip}:2380 --listen-peer-urls http://${localip}:2380 --listen-client-urls http://${pubip}:2379 --advertise-client-urls http://${pubip}:2379 --initial-cluster-token my-etcd-token --initial-cluster etcd0=http://192.168.5.84:2380,etcd1=http://192.168.5.85:2380,etcd2=http://192.168.2.77:2380 --initial-cluster-state new >> /var/log/etcd.log 2>&1 &
# cat etcd-start.sh
#获取IP
localip=`ifconfig em2|grep -w inet| awk ‘{print $2}‘|awk -F: ‘{print $2}‘`
pubip=0.0.0.0
#启动服务
etcd --name etcd1 -data-dir /var/lib/etcd --initial-advertise-peer-urls http://${localip}:2380 --listen-peer-urls http://${localip}:2380 --listen-client-urls http://${pubip}:2379 --advertise-client-urls http://${pubip}:2379 --initial-cluster-token my-etcd-token --initial-cluster etcd0=http://192.168.5.84:2380,etcd1=http://192.168.5.85:2380,etcd2=http://192.168.2.77:2380 --initial-cluster-state new >> /var/log/etcd.log 2>&1 &
# cat etcd-start.sh
#获取IP
localip=`ifconfig bond0|grep -w inet| awk ‘{print $2}‘|awk -F: ‘{print $2}‘`
pubip=0.0.0.0
#启动服务
etcd --name etcd2 -data-dir /var/lib/etcd --initial-advertise-peer-urls http://${localip}:2380 --listen-peer-urls http://${localip}:2380 --listen-client-urls http://${pubip}:2379 --advertise-client-urls http://${pubip}:2379 --initial-cluster-token my-etcd-token --initial-cluster etcd0=http://192.168.5.84:2380,etcd1=http://192.168.5.85:2380,etcd2=http://192.168.2.77:2380 --initial-cluster-state new >> /var/log/etcd.log 2>&1 &