Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

528
Visualizações
how to change the control-palne,master node's name in kube1.20.2

I succeeded in setup a control-plane,master node in my vm. Then I copied the vm, trying to join the copied vm to the existed kubernete cluster.

Problem is that the original vm(node)'s name is new-master-1, and the copied node has the same name. Even after I vi /etc/hostname and change the copied vm's name to new-master-2, after running kubectl get nodes in the copied vm, the output name is still new-master-1:

root@new-master-2:/home/hzg# kubectl get nodes
NAME           STATUS   ROLES                  AGE   VERSION
new-master-1   Ready    control-plane,master   32h   v1.20.2

I think I can only join the copied vm as another master node to the cluster after I see that the name change to new-master-2, right? How to change the node's name?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

TL;DR:

Run: kubeadm join - adjust this command based on the output from kubeadm token create and add flags like --control-plane and --node-name if needed. Take a look at the kubeadm join before proceeding.


The kubelet registers a node under a particular name. And usually you can Reconfigure a Node's Kubelet in a Live Cluster. But it does not apply when it comes to changing the Node's name. If you try to use kubectl edit node for that, you will get an error:

error: At least one of apiVersion, kind and name was changed

There is a way however. You need to change the hostname and than remove the Node, reset and rejoin it.

Here are the steps. On the Node that needs its name to be changed:

  • Change the hostname.

  • Run: kubectl delete node <nodename> (notice that you still have to use the old Node name)

  • Run: kubeadm reset (as root if needed)

Now, on the original Master Node:

  • Run: export KUBECONFIG=/path/to/admin.conf

  • Run: kubeadm token create --print-join-command

Back on the renamed Node:

  • Run: kubeadm join - adjust this command based on the output from kubeadm token create and add flags like --control-plane and --node-name if needed. Take a look at the kubeadm join before proceeding.

You can check out this source for a tutorial video.


EXAMPLE:

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 

Result: the name of kube-node-2 was successfully changed to kube-node-22

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda