有些女子,明知很不好,可就是放不下的。 ——烽火戏诸侯《雪中悍刀行》
高版本需要修改docker资源管理为systemd
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible master,node -m shell -a "sed -i '3i ,\"exec-opts\": [\"native.cgroupdriver=systemd\"]' /etc/docker/daemon.json" ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible master,node -m shell -a "systemctl restart docker"
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible master,node -m shell -a "kubeadm reset -f"
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible master -m shell -a "kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version=v1.22.2 --pod-network-cidr=10.244.0.0/16"
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$mkdir -p $HOME/.kube ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ sudo chown $(id -u):$(id -g) $HOME/.kube/config ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$export KUBECONFIG=/etc/kubernetes/admin.conf
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$kubectl get nodes NAME STATUS ROLES AGE VERSION vms81.liruilongs.github.io NotReady control-plane,master 89s v1.22.2
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$kubeadm token create --print-join-command kubeadm join 192.168.26.81:6443 --token e5uvm8.06sov2egw6j8570k --discovery-token-ca-cert-hash sha256:2e17952177d9c633254e6941849885fc8e0e16dde805425effa22ed04415e7d4 ┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible node -m shell -a "kubeadm join 192.168.26.81:6443 --token e5uvm8.06sov2egw6j8570k --discovery-token-ca-cert-hash sha256:2e17952177d9c633254e6941849885fc8e0e16dde805425effa22ed04415e7d4"
这里的资源文件,镜像是之前导入的
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$kubectl apply -f calico.yaml
┌──[root@vms81.liruilongs.github.io]-[~/ansible] └─$kubectl get nodes NAME STATUS ROLES AGE VERSION vms81.liruilongs.github.io Ready control-plane,master 9m40s v1.22.2 vms82.liruilongs.github.io Ready <none> 3m39s v1.22.2 vms83.liruilongs.github.io Ready <none> 3m37s v1.22.2