Remove Member Clusters

This section explains how to remove member clusters.

Note
  • The host cluster cannot be removed.

  • After removing a member cluster, KubeSphere will no longer manage that cluster. Existing Kubernetes resources in the cluster will not be deleted.

Warning

After a cluster is removed, the existing multi-cluster configuration data in the cluster will not be automatically cleared. Uninstalling KubeSphere or deleting associated resources may result in data loss. Be sure to follow the Clean up Multi-Cluster Configuration Data steps on the removed cluster.

Prerequisites

You should have the platform-admin role on both the host cluster and the member clusters you want to remove.

Remove Clusters via the Web Console

  1. Log in to the KubeSphere web console of the host cluster with a user having the platform-admin role.

  2. Click Cluster Management.

  3. Click more on the right side of the cluster you want to remove, then select Remove Cluster from the dropdown list.

  4. In the Remove Cluster dialog, confirm the information of the cluster to be removed, drag the slider to the right, enter the name of the cluster to be removed, choose to either delete or keep all notification configuration data in the cluster, then click Remove.

    Note

    In a multi-cluster system, notification channels, silence rules, notification languages, and other configuration data on the host cluster will be automatically synchronized to member clusters. If you do not choose to delete all notification configuration data in the cluster when removing the cluster, notifications will continue to be sent according to the original configuration even after the cluster is removed.

Remove Clusters via Command Line

In certain situations, you may not be able to remove member clusters via the web console, for example, if there are credential errors for the member cluster. In such cases, you can follow these steps to remove unhealthy member clusters via the command line:

  1. Log in to the KubeSphere web console of the host cluster with a user having the platform-admin role.

  2. Hover over hammer in the bottom right corner of the page, then click kubectl in the menu.

  3. In the kubectl dialog, run the following command to remove the member cluster (replace <cluster name> with the name of the member cluster):

    1. kubectl delete cluster <cluster name>

Clean up Multi-Cluster Configuration Data

Log in to the node of the removed cluster, run the following command to clean up the multi-cluster configuration data in the cluster:

  1. for ns in $(kubectl get ns --field-selector status.phase!=Terminating -o jsonpath='{.items[*].metadata.name}'); do kubectl label ns $ns kubesphere.io/workspace- && kubectl patch ns $ns --type merge -p '{"metadata":{"ownerReferences":[]}}'; done