This page describes how to manually unregister a cluster from a Google Cloud fleet. When you manually unregister a cluster, its connection to the fleet is removed but the cluster remains.
You can unregister GKE clusters on Google Cloud and attached third-party clusters.
Note that moving registered clusters between fleets (unregistering then reregistering) is not currently recommended, as it can result in unexpected or unwanted behavior: for example, your workloads' fleet Workload Identity will change, potentially resulting in blocked requests and outages. The recommended approach is to create a new cluster in the fleet in which you want your workloads to reside, then move your workloads from your old cluster to the new cluster.
Unregister a cluster
gcloud
Unregister a GKE cluster
This command can currently only be used to unregister GKE clusters registered using gcloud container clusters update
or gcloud container clusters create
.
Run the following command:
gcloud beta container clusters update CLUSTER_NAME --clear-fleet-project
where:
- CLUSTER_NAME is the cluster's name.
Deleting a registered cluster with gcloud container clusters delete
also deletes the cluster's fleet membership.
Unregister a GKE cluster (legacy command)
Run either of the following commands:
gcloud container fleet memberships unregister [MEMBERSHIP_NAME] \ --project=[PROJECT_ID] \ --gke-uri=[GKE_URI]
gcloud container fleet memberships unregister [MEMBERSHIP_NAME] \ --project=[PROJECT_ID] \ --gke-cluster=[GKE_CLUSTER]
where:
- [PROJECT_ID] is your Google Cloud project ID. Learn how to find this value.
- [MEMBERSHIP_NAME] is the membership name that corresponds to your
cluster. To list all the memberships on the Hub, run:
gcloud container fleet memberships list
. - [GKE_URI] is the URI of the GKE cluster,
for example: 'https://container.googleapis.com/projects/my-project/locations/us-central1-a/clusters/my-cluster'.
You can obtain the URI by running
gcloud container clusters list --uri
. The provided URI will be validated to confirm that it maps to the valid GKE cluster. - [GKE_CLUSTER] is the
location/name
of the GKE cluster. The location can be a zone or a region for example:us-central1-a/my-cluster
.
Unregister an EKS or AKS attached cluster
These instructions apply to Amazon EKS and Azure AKS clusters registered using the latest version of our attached clusters feature. Clusters attached using the previous generation of this feature should follow the instructions in the next section.
Unregister any other attached cluster type
Run the following command:
gcloud container fleet memberships unregister [MEMBERSHIP_NAME] \ --project=[PROJECT_ID] \ --context=[KUBECONFIG_CONTEXT] \ --kubeconfig=[KUBECONFIG_PATH]
where:
- [PROJECT_ID] is your Google Cloud project ID. Learn how to find this value.
- [MEMBERSHIP_NAME] is the membership name that corresponds to your
cluster. To get list of all the memberships on the Hub, run:
gcloud container fleet memberships list
. - [KUBECONFIG_PATH] is the local filepath where your
kubeconfig containing an entry for the cluster file is stored.
This defaults to
$KUBECONFIG
if that environment variable is set, otherwise this defaults to$HOME/.kube/config
. - [KUBECONFIG_CONTEXT] is the cluster's context as it
appears in the kubeconfig file. You can get this value from the command
line by running
kubectl config current-context
.
Console
Unregister a GKE cluster
To unregister a GKE cluster:
Go to the Anthos Clusters page. This page shows all your registered clusters.
Select the cluster you want to unregister from the list. A details panel displays.
In the details panel, click Unregister.
In the dialog that displays, click Unregister again to confirm the action.
Unregister any other cluster type
To unregister any other fleet cluster:
In the Google Cloud console, go to the GKE clusters page.
In the list of clusters, click
Actions next to the registered cluster, and then click Deregister.In the dialog that displays, click Deregister again to confirm the action.
Verify that the Connect Agent namespace is deleted (Optional)
After you unregister a cluster, you can verify that the namespace used by the Connect Agent has been deleted. This applies to registrations that install the Connect Agent only. To do so, run:
kubectl get ns -l hub.gke.io/project
If this command returns no output, the namespace has already been deleted.
Delete the Google Cloud Service Account
If you created a service account for the Connect Agent, you can delete it as follows:
gcloud iam service-accounts delete [SERVICE_ACCOUNT_NAME]
Unregister an unavailable cluster
If you want to unregister a cluster that you can no longer access, perform the following steps:
List the clusters (a.k.a memberships) that are currently registered:
gcloud container fleet memberships list
In the command output, the
Name
column lists the membership names of registered clusters, and theEXTERNAL_ID
column lists the clusters' UIDs of the kube-system namespace.To unregister an unavailable cluster, run the following command:
gcloud container fleet memberships delete [MEMBERSHIP_NAME]
where [MEMBERSHIP_NAME] is the membership name that corresponds to your cluster.