2

I've set up a new kubernetes cluster using k3s. When I run kubectl top nodes there are 6 listed even though the cluster only has 4 nodes. Some of the hosts have changed hostnames since first being set up, and both the new and old hostnames are listed.

How can I remove the old hostnames from kubectl?

slondr
  • 163

1 Answers1

1

Hostname getting changed is a serious issue, it will result in the termination of your pods running on that particular node, so you need to take care while creating your cluster and assign fixed hostnames to your nodes. In general even though the IP gets changed the hostname should remain constant except if someone overrides the existing hostname or if someone adds multiple hostnames in the same machine or node.

Check whether there are any conflicting entries in the hostnames file, remove them accordingly and restart the kubelet service, if the issue still persists use the below commands:

  • Using the kubectl command, list all the existing nodes and try to differentiate the old nodes from new nodes.

  • After differentiating the old nodes, delete them by using the following command and this will solve the issue for you.

    kubectl delete node <hostname>