I have a running node in a kubernetes cluster. Is there a way I can change its name?
I have tried to
- delete the node using kubectl delete
- change the name in the node's manifest
- add the node back.
But the node won't start.
Anyone know how it should be done?
Thanks
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:
Then on the node that you want to rejoin, as root:
check the output and see if it applies to your setup (for potential further cleanup).
Now generate the join command on the master node:
Run the output on the worker node you have just reset:
If you run
kubectl get nodes
it should show up now with the new nameoutput in my case:
Enjoy your renamed node!
Based on source: https://www.youtube.com/watch?v=TqoA9HwFLVU
Usualy it's kubelet that is responsible for registering the node under particular name, so you should make changes to your nodes kubelet configuration and then it should pop up as new node.