Unregistering a cluster

This page describes how to manually unregister a cluster from Google Cloud. When you manually unregister a cluster, its connection to Google Cloud is removed but the cluster remains.

Unregister a cluster

gcloud

Unregister a non-GKE or Anthos GKE on-prem cluster

Run the following command:

gcloud container hub 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 hub 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.

Unregister a GKE cluster

Run either of the following commands:

gcloud container hub memberships unregister [MEMBERSHIP_NAME] \
   --gke-uri=[GKE_URI]
gcloud container hub memberships unregister [MEMBERSHIP_NAME] \
   --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 hub 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.

Console

To unregister a cluster, perform the following steps:

  1. Visit the Kubernetes Engine menu in Cloud Console.

    Visit the Kubernetes Engine menu

  2. From the list of clusters, click the trash icon beside the registered cluster.

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. 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 GCP Service Account

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:

  1. List the clusters (a.k.a memberships) that are currently registered:

    gcloud container hub memberships list

    In the command output, the Name column lists the membership names of registered clusters, and the EXTERNAL_ID column lists the clusters' UIDs of the kube-system namespace.

  2. To unregister an unavailable cluster, run the following command:

    gcloud container hub memberships delete [MEMBERSHIP_NAME]

    where [MEMBERSHIP_NAME] is the membership name that corresponds to your cluster.