Remove Cluster Nodes

This section describes how to delete KubeSphere cluster nodes.

The open-source tool KubeKey will be used during the process. For more information about KubeKey, please visit GitHub KubeKey repository.

Note

The node deletion method described in this section is only applicable to Kubernetes installed through KubeKey. If your Kubernetes is not installed via KubeKey, please refer to Kubernetes Documentation to delete nodes.

Warning
  • Do not delete control plane nodes, otherwise the cluster may encounter errors.

  • Please ensure that after node deletion, the remaining resources in the cluster are still sufficient to run existing services. Otherwise, service interruption may occur after the node is deleted.

Prerequisites

  • You should get the installation configuration file config-sample.yaml and transfer it to the cluster node where you will perform this action. For more information, refer to Install Kubernetes and KubeSphere.
Warning

If you are unable to get the installation configuration file config-sample.yaml, you need to refer to Install Kubernetes and KubeSphere to recreate the config-sample.yaml file. When recreating the file, make sure that the cluster information in the file matches the current state of the cluster. Otherwise, the uninstallation process may encounter errors.

Steps

  1. If you are accessing GitHub/Googleapis from a restricted location, please log in to any cluster node and run the following command to set the download region:

    1. export KKZONE=cn
  2. Run the following command to download the latest version of KubeKey:

    1. curl -sfL https://get-kk.kubesphere.io | sh -

    After the download is complete, a KubeKey binary file kk will be generated in the current directory.

    Note

    If the cluster node used to perform the operations cannot connect to the internet, you can manually download KubeKey on a device with internet access and then transfer it to the cluster node.

  3. Add execute permission to the KubeKey binary file kk:

    1. sudo chmod +x kk
  4. Execute the following command to get the name of the node that needs to be deleted:

    1. kubectl get node
  5. Execute the following command to evict the pods running on the node that needs to be deleted to other nodes (replace <node name> with the name of the node that needs to be deleted):

    1. kubectl drain <node name>
  6. Transfer the installation configuration file config-sample.yaml to the current directory.

  7. Execute the following command to start deleting nodes:

    1. ./kk delete node <node name> -f config-sample.yaml
  8. Execute the following command to view the current cluster nodes:

    1. kubectl get node

    If the deleted node is not displayed, it means the node is deleted successfully.