环境:centos7、三个主节点的kubernetes
1、关闭selinux、firewalld、swap
2、修改主机名称 hostnamectl set-hostname master1
3、更新系统时间 timedatectl set-timezone Asia/Shanghai
4、上传文件(准备中。。。)
kube1.17.2.tar.gz
sealos
5、配置sealos工具
chmod +x sealos && mv sealos /usr/bin
6、配置hosts
cat <<EOF >>/etc/hosts
172.21.210.4 master1
172.21.210.5 master2
172.21.210.6 master3
172.21.210.7 node1
EOF
7、安装k8s集群
sealos init --master 172.21.210.4 \
--master 172.21.210.5 \
--master 172.21.210.6 \
--node 172.21.210.7 \
--user root \
--passwd server-passwd \ #替换为服务器密码
--version v1.17.2 \
--pkg-url /root/kube1.17.2.tar.gz
8、添加新节点
kubeadm token create --print-join-command #获取token kubeadm join apiserver.cluster.local:6443 --token uqdcs4.svi229q32vvh098d --discovery-token-ca-cert-hash sha256:460de3edc9bfdc49226249937ae0db4d51d731dffb8859d00a9fb0a396dfefa2 scp -r kube root@172.19.163.142:/root/ #复制安装包到新节点 cd kube/shell && chmod u+x init.sh && ./init.sh #新节点进行初始 sed -i "s/127.0.0.1/172.21.210.20/g" /etc/docker/daemon.json #配置自己的harbor地址 systemctl restart docker docker login 172.21.210.20 #登录harbor admin echo "10.103.97.2 apiserver.cluster.local" >> /etc/hosts # using vip 这儿不变 kubeadm join 10.103.97.2:6443 --token uqdcs4.svi229q32vvh098d \ #token为上面获取的token --master 172.21.210.4:6443 --master 172.21.210.5:6443 --master 172.21.210.6:6443 --discovery-token-ca-cert-hash sha256:460de3edc9bfdc49226249937ae0db4d51d731dffb8859d00a9fb0a396dfefa2
9、进行验证
[root@master1 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master1 Ready master 30h v1.17.2 master2 Ready master 30h v1.17.2 master3 Ready master 30h v1.17.2 node1 Ready <none> 30h v1.17.2