This section describes how to remove a member cluster.

Note
  • The host cluster cannot be removed.

  • After a member cluster is removed, KubeSphere will no longer be able to manage that cluster. The 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 cleaned up. Uninstalling KubeSphere or deleting associated resources may lead to user data loss. Be sure to perform the Clean Up Multi-cluster Configuration Data steps on the removed cluster.

Prerequisites

You need to have the platform-admin role in both the host cluster and the member cluster to be removed.

Remove Cluster via Web Console

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

  2. Click Cluster Management.

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

  4. In the Remove Cluster dialog box, confirm the information of the cluster to be removed, drag the slider to the right, enter the name of the cluster to be removed, and then click Remove.

Remove Cluster via Command Line

In some cases, it may not be possible to remove a member cluster from the web console. For example, if the member cluster’s credentials are incorrect. In such cases, you can perform the following steps to remove an unhealthy member cluster via the command line:

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

  2. Click the Component Dock in the upper-right corner of the page and select kubectl.

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

    kubectl delete cluster <cluster name>

Clean Up Multi-cluster Configuration Data

Log in to the node of the removed member cluster and execute the following command to clean up the multi-cluster configuration data in the cluster:

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