gcloud container hub memberships unregister

NAME
gcloud container hub memberships unregister - unregister a cluster from a fleet
SYNOPSIS
gcloud container hub memberships unregister(MEMBERSHIP_NAME :--location=LOCATION)(--gke-cluster=LOCATION/CLUSTER_NAME    |--gke-uri=GKE_URI    | [--context=CONTEXT :--kubeconfig=KUBECONFIG])[--uninstall-connect-agent][GCLOUD_WIDE_FLAG]
DESCRIPTION
This command unregisters a cluster with the fleet by:
1.DeletingtheFleetMembershipresourceforthiscluster(a.k.a`gcloudcontainerhubmembershipsdelete`).2.Removingthecorrespondingin-clusterKubernetesResourcesthatmaketheclusterexclusivetoonefleet(a.k.a`kubectldeletemembershipsmembership`).3.[OptionalforGKEcluster]UninstallingtheConnectagentfromthiscluster(a.k.a`kubectldeleteonthegke-connectnamespace`).

The unregister command makes additional internal checks to ensure that all threesteps can be safely done to properly clean-up in-Fleet and in-cluster resources.

To unregister a GKE cluster use--gke-cluster or--gke-uri flag (no--kubeconfig flag is required).

To unregister a third-party cluster use--context flag (with anoptional --kubeconfig`s flag).

To only delete the Fleet Membership resource, consider using the command:gcloudcontainer hub memberships delete. This command is intended to deletestale Fleet Membership resources as doing so on a fully registered cluster willskip some of the steps above and orphan in-cluster resources and agentconnections to Google.

EXAMPLES
Unregister a third-party cluster referenced from a specific kubeconfig file:
gcloudcontainerhubmembershipsunregistermy-membership--context=my-cluster-context--kubeconfig=/home/user/custom_kubeconfig

Unregister a third-party cluster referenced from the default kubeconfig file:

gcloudcontainerhubmembershipsunregistermy-membership--context=my-cluster-context

Unregister a GKE cluster referenced from a GKE URI:

gcloudcontainerhubmembershipsunregistermy-membership--gke-uri=my-cluster-gke-uri

Unregister a GKE cluster referenced from a GKE Cluster location and name:

gcloudcontainerhubmembershipsunregistermy-membership--gke-cluster=my-cluster-region-or-zone/my-cluster

Unregister a GKE cluster and uninstall Connect agent:

gcloudcontainerhubmembershipsunregistermy-membership--gke-cluster=my-cluster-region-or-zone/my-cluster--uninstall-connect-agent
POSITIONAL ARGUMENTS
Membership resource - The group of arguments defining a membership. Thearguments in this group can be used to specify the attributes of this resource.(NOTE) Some attributes are not given arguments in this group but can be set inother ways.

To set theproject attribute:

  • provide the argumentMEMBERSHIP_NAME on the command line with afully specified name;
  • provide the argument--project on the command line;
  • set the propertycore/project.

This must be specified.

MEMBERSHIP_NAME
ID of the membership or fully qualified identifier for the membership.

To set themembership attribute:

  • provide the argumentMEMBERSHIP_NAME on the command line.

This positional argument must be specified if any of the other arguments in thisgroup are specified.

--location=LOCATION
The location of the membership resource, e.g.us-central1. If notspecified, defaults toglobal.To set thelocation attribute:
  • provide the argumentMEMBERSHIP_NAME on the command line with afully specified name;
  • provide the argument--location on the command line;
  • set the propertygkehub/location.
REQUIRED FLAGS
Cluster identifier.

Exactly one of these must be specified:

--gke-cluster=LOCATION/CLUSTER_NAME
The location/name of the GKE cluster. The location can be a zone or a region fore.gus-central1-a/my-cluster.
--gke-uri=GKE_URI
The URI of a GKE cluster that you want to register to Hub; for example,'https://container.googleapis.com/v1/projects/my-project/locations/us-central1-a/clusters/my-cluster'.To obtain the URI, you can run 'gcloud container clusters list --uri'. Note thatthis should only be provided if the cluster being registered is a GKE cluster.The service will validate the provided URI to confirm that it maps to a validGKE cluster."
Non-GKE cluster identifier.
--context=CONTEXT
The cluster context as it appears in the kubeconfig file. You can get this valuefrom the command line by running command:kubectl configcurrent-context.

This flag argument must be specified if any of the other arguments in this groupare specified.

--kubeconfig=KUBECONFIG
The kubeconfig file containing an entry for the cluster. Defaults to $KUBECONFIGif it is set in the environment, otherwise defaults to $HOME/.kube/config.
OPTIONAL FLAGS
--uninstall-connect-agent
If set to True for a GKE cluster, Connect agent will be uninstalled from thecluster. No-op for third-party clusters, where Connect agent will always beuninstalled.
GCLOUD WIDE FLAGS
These flags are available to all commands:--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.

Run$gcloud help for details.

NOTES
These variants are also available:
gcloudalphacontainerhubmembershipsunregister
gcloudbetacontainerhubmembershipsunregister

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-22 UTC.