我在kubernetes集群中有一个正在运行的节点。有什么办法可以更改它的名称?
我试图
但是节点不会启动。
有人知道应该怎么做吗?
谢谢
Changing the node's name is not possible at the moment, it requires you to remove and rejoin the node. You need to make sure the hostname is changed to the new name, remove the node, reset it and rejoin it.
(you will notice that with the command : kubectl edit node , you will get an error if you try and save the name: A copy of your changes has been stored to "/tmp/kubectl-edit-qlh54.yaml" error: At least one of apiVersion, kind and name was changed )
Ideally you have removed the running pods on it.
You can try to run kubectl drain <node_name_to_rename>
. Proceed at your own risk if that doesn't complete . --ignore-daemon-sets can be used to ignore possible issues for pods that cannot be evicted.
In short, for a node that has been renamed and is out of the cluster on CentOS 7:
kubectl delete node <original-nodename>
Run Code Online (Sandbox Code Playgroud)
Then on the node that you want to rejoin, as root:
kubeadm reset
Run Code Online (Sandbox Code Playgroud)
check the output and see if it applies to your setup (for potential further cleanup).
Now generate the join command on the master node:
export KUBECONFIG=/etc/kubernetes/admin.conf #(or wherever you have it)
kubeadm token create --print-join-command
Run Code Online (Sandbox Code Playgroud)
Run the output on the worker node you have just reset:
kubeadm join <masternode_ip_address>:6443 --token somegeneratedtoken --discovery-token-ca-cert-hash sha256:somesha256hashthatyougotfromtheabovecommand
Run Code Online (Sandbox Code Playgroud)
If you run kubectl get nodes
it should show up now with the new name
output in my case:
W0220 10:43:23.286109 11473 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.17" ConfigMap in the kube-system namespace
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...
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.
Run Code Online (Sandbox Code Playgroud)
Enjoy your renamed node!
Based on source: https://www.youtube.com/watch?v=TqoA9HwFLVU
通常,kubelet负责以特定名称注册节点,因此您应该更改节点kubelet配置,然后将其弹出作为新节点。
归档时间: |
|
查看次数: |
7398 次 |
最近记录: |