kubernetes1.17.2離線安裝
阿新 • • 發佈:2020-07-10
環境: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.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 kubeView Code/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.2View Code