简体   繁体   中英

How to deregister a kubernetes node from a kubernetes cluster

I have a node mistakenly registered on a cluster B while it is actually serving for cluster A.

Here 'registered on a cluster B' means I can see the node from kubectl get node from cluster B.

I want to deregister this node from cluster B, but keep the node intact.

I know regular process to delete a node is:

kubectl drain node xxx
kubectl delete node xxx
# on node
kubeadm reset

But I do not want pods on the node from cluster A to be deleted or transfered. And I want to make sure the node would not self-register to cluster B afterwards.

To be clear, let's say, cluster A has Pod A on the node, cluster B has Pod B on the node as well, I want to delete node from cluster B, but keep Pod A intact. (By the way, can I see Pod A from cluster B?)

Thank you in advance!

To deregister the node without removing any pod you run below command

kubectl delete node nodename

After this is done the node will not appear in kubectl get nodes

For the node to not self register again stop the kubelet process on that node by logging into that node and using below command.

systemctl stop kubelet

As this case has been already clarified I decided to publish a Community Wiki answer based on the following comment:

@mario nvm, I thought different clusters in one node affect each other, actually they do not, they just share container runtime which is more like 'read-only', and they have different kubelets of themselves listening on different port. – Li Ziyan Aug 17 at 5:29

to make it clear also for other users what was actually the issue here and how it has been solved or simply clarified.

So if you design your infrastructure in such a way that you use one physical (or virtual) machine as Node for more than one kubernetes clusters (which I believe is not very common case) the infrastructure looks as follows:

  1. Components that are shared :
  • physical (or virtual) node
  • common container runtime environment (eg docker)
  1. Components that are separate :
  • two separate kubelets . Although they are running on the same physical/virtual node they are configured to listen on different ports and are registered within two master Nodes (or more specifically two different kube-apiservers being part of two different kubernetes control planes )
  • two logically separate, independent kubernetes Nodes which, although they are configured on the same physical node/host , are logically completely separate kubernetes Nodes , being part of two completely different kubernetes clusters that don't interfere with each other in any way.

I hope it helps to clarify possible confusion about this question and maybe help someone in case they have similar doubts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM