由於幾臺伺服器都用相同的外部external ip,而新增k8s節點時有外部ip先使用外部ip,所以會顯示節點已新增,無法新增成功,此時需要用--address引數來指定內部ip,這樣節點就由內部ip來新增
如下新增k8s節點的命令:
sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.6.11 --server https://rancher.xxx.com --token xxxxxxx --address 10.xx.xx.xx --etcd --controlplane --worker
另外,如果節點新增有問題,需要刪除重新新增,需要先做一系列清理工作,否則再次新增該節點會有問題。
直接使用指令碼,可以清理乾淨
docker rm -f $(sudo docker ps -aq); docker volume rm $(sudo docker volume ls -q); rm -rf /etc/cni \ /etc/kubernetes \ /opt/cni \ /opt/rke \ /run/secrets/kubernetes.io \ /run/calico \ /run/flannel \ /var/lib/calico \ /var/lib/etcd \ /var/lib/cni \ /var/lib/kubelet \ /var/lib/rancher/rke/log \ /var/log/containers \ /var/log/pods \ /var/run/calico for mount in $(mount | grep tmpfs | grep '/var/lib/kubelet' | awk '{ print $3 }') /var/lib/kubelet /var/lib/rancher; do umount $mount; done rm -f /var/lib/containerd/io.containerd.metadata.v1.bolt/meta.db sudo systemctl restart containerd sudo systemctl restart docker