由于几台服务器都用相同的外部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
标签:run,lib,--,var,添加,rancher,节点 From: https://www.cnblogs.com/xiaoxiaomuyuyu/p/18203247