TL;博士:
运行:kubeadm join
- 根据输出调整此命令kubeadm token create
并添加标志--control-plane
,--node-name
如需要。在继续之前查看kubeadm join 。
以kubelet
特定名称注册节点。通常您可以在 Live Cluster 中重新配置节点的 Kubelet。但它不适用于更改节点的名称。如果你尝试使用kubectl edit node
它,你会得到一个错误:
error: At least one of apiVersion, kind and name was changed
不过有办法。您需要更改主机名,然后删除节点,重置并重新加入它。
以下是步骤。在需要更改名称的节点上:
现在,在原始主节点上:
回到重命名的节点:
- 运行:
kubeadm join
- 根据输出调整此命令kubeadm token create
并添加标志--control-plane
,--node-name
如需要。在继续之前查看kubeadm join 。
您可以查看此资源以获取教程视频。
例子:
kube-master:~$ kubectl get nodes
NAME STATUS
kube-master Ready
kube-node-1 Ready
kube-node-2 Ready
kube-master:~$ kubectl delete node kube-node-2
node "kube-node-2" deleted
kube-node-2:~$ sudo kubeadm reset
[reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
[reset] Are you sure you want to proceed? [y/N]: y
kube-node-2:~$ sudo kubeadm join --node-name kube-node-22 <rest-of-the-join-command>
This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.
Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
kube-master:~$ kubectl get nodes
NAME STATUS
kube-master Ready
kube-node-1 Ready
kube-node-22 Ready
结果:名字kube-node-2
成功改成kube-node-22