gcloud beta container hub memberships register Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud beta container hub memberships register - register a cluster with a fleet
- SYNOPSIS
gcloud beta container hub memberships register(MEMBERSHIP_NAME:--location=LOCATION)(--gke-cluster=LOCATION/CLUSTER_NAME|--gke-uri=GKE_URI| [--context=CONTEXT:--kubeconfig=KUBECONFIG])[--install-connect-agent][--internal-ip][--manifest-output-file=MANIFEST_OUTPUT_FILE][--proxy=PROXY][--service-account-key-file=SERVICE_ACCOUNT_KEY_FILE| [--enable-workload-identity:--has-private-issuer|--public-issuer-url=PUBLIC_ISSUER_URL]][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(BETA)This command registers a cluster with the fleet by:1.CreatingaFleetMembershipresourcecorrespondingtothecluster.2.Addingin-clusterKubernetesResourcesthatmaketheclusterexclusivetoonefleet.3.InstallingtheConnectagentintothiscluster(optionalforGKE).
A successful registration implies that the cluster is now exclusive to a singleFleet. If the cluster is already registered to another Fleet, the registrationwill not be successful.
To register a GKE cluster, use
--gke-clusteror--gke-uriflag (no--kubeconfigflag is required).Connect agent will not be installed by default for GKE clusters. To install it,specify--install-connect-agent. The default value for--locationis the same as the cluster's region or zone, can bespecified asglobal.Anthos clusters on VMware, bare metal, AWS, and Azure are registered with afleet when the clusters are created. To register Amazon EKS clusters, seeAttachyour EKS cluster. To regiser Microsoft Azure clusters, seeAttachyour AKS cluster.
To register a third-party cluster, use --context flag (with an optional--kubeconfig flag). Connect agent will always be installed for these clusters.
If Connect agent is to be installed, its authentication needs to be configuredby
--enable-workload-identityor--service-account-key-file. For the latter case, the correspondingservice account must have been grantedgkehub.connectpermissions.For more information about Connect agent, go to:https://cloud.google.com/anthos/multicluster-management/connect/overview/Rerunning this command against the same cluster with the same MEMBERSHIP_NAMEand target fleet is successful, and will upgrade the Connect agent if it issupposed to be installed and a newer version is available. Rerunning with
--enable-workload-identityensures that Workload Identity isenabled on the cluster.- EXAMPLES
- Register a non-GKE cluster referenced from a specific kubeconfig file, andinstall the Connect agent:
gcloudbetacontainerhubmembershipsregistermy-cluster--context=my-cluster-context--kubeconfig=/home/user/custom_kubeconfig--service-account-key-file=/tmp/keyfile.jsonRegister a non-GKE cluster referenced from the default kubeconfig file, andinstall the Connect agent:
gcloudbetacontainerhubmembershipsregistermy-cluster--context=my-cluster-context--service-account-key-file=/tmp/keyfile.jsonRegister a non-GKE cluster, and install a specific version of the Connect agent:
gcloudbetacontainerhubmembershipsregistermy-cluster--context=my-cluster-context--version=gkeconnect_20190802_02_00--service-account-key-file=/tmp/keyfile.jsonRegister a non-GKE cluster and output a manifest that can be used to install theConnect agent by kubectl:
gcloudbetacontainerhubmembershipsregistermy-cluster--context=my-cluster-context--manifest-output-file=/tmp/manifest.yaml--service-account-key-file=/tmp/keyfile.jsonRegister a GKE cluster referenced from a GKE URI:
gcloudbetacontainerhubmembershipsregistermy-cluster--gke-uri=my-cluster-gke-uriRegister a GKE cluster referenced from a GKE URI, and install the Connect agentusing service account key file:
gcloudbetacontainerhubmembershipsregistermy-cluster--gke-uri=my-cluster-gke-uri--install-connect-agent--service-account-key-file=/tmp/keyfile.jsonRegister a GKE cluster and output a manifest that can be used to install theConnect agent by kubectl:
gcloudbetacontainerhubmembershipsregistermy-cluster--gke-uri=my-cluster-gke-uri--enable-workload-identity--install-connect-agent--manifest-output-file=/tmp/manifest.yamlRegister a GKE cluster first, and install the Connect agent later.
gcloudbetacontainerhubmembershipsregistermy-cluster--gke-cluster=my-cluster-region-or-zone/my-clustergcloudbetacontainerhubmembershipsregistermy-cluster--gke-cluster=my-cluster-region-or-zone/my-cluster--install-connect-agent--enable-workload-identityRegister a GKE cluster, and install a specific version of the Connect agent:
gcloudbetacontainerhubmembershipsregistermy-cluster--gke-cluster=my-cluster-region-or-zone/my-cluster--install-connect-agent--version=20220819-00-00--service-account-key-file=/tmp/keyfile.jsonRegister a GKE cluster and output a manifest that can be used to install theConnect agent:
gcloudbetacontainerhubmembershipsregistermy-cluster--gke-uri=my-cluster-gke-uri--install-connect-agent--manifest-output-file=/tmp/manifest.yaml--service-account-key-file=/tmp/keyfile.json - 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 the
projectattribute:- provide the argument
MEMBERSHIP_NAMEon the command line with afully specified name; - provide the argument
--projecton the command line; - set the property
core/project.
This must be specified.
MEMBERSHIP_NAME- ID of the membership or fully qualified identifier for the membership.
To set the
membershipattribute:- provide the argument
MEMBERSHIP_NAMEon the command line.
This positional argument must be specified if any of the other arguments in thisgroup are specified.
- provide the argument
--location=LOCATION- The location for the membership resource, e.g.
us-central1. If notspecified, defaults toglobal. Not supported for GKE clusters,whose membership location will be the location of the cluster.To set thelocationattribute:- provide the argument
MEMBERSHIP_NAMEon the command line with afully specified name; - provide the argument
--locationon the command line; - set the property
gkehub/location.
- provide the argument
- provide the argument
- 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.
- 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.g
us-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.
- Cluster identifier.
- OPTIONAL FLAGS
--install-connect-agent- If set to True for a GKE cluster, Connect agent will be installed in thecluster. No-op for Non-GKE clusters, where Connect agent will always beinstalled.
--internal-ip- Whether to use the internal IP address of the cluster endpoint.
--manifest-output-file=MANIFEST_OUTPUT_FILE- The full path of the file into which the Connect agent installation manifestshould be stored. If this option is provided, then the manifest will be writtento this file and will not be deployed into the cluster by gcloud, and it willneed to be deployed manually.
--proxy=PROXY- The proxy address in the format of http[s]://{hostname}. The proxy must supportthe HTTP CONNECT method in order for this connection to succeed.
- At most one of these can be specified:
--service-account-key-file=SERVICE_ACCOUNT_KEY_FILE- The JSON file of a Google Cloud service account private key. This serviceaccount key is stored as a secret named
in gke-connect namespace. Toupdate thecreds-gcpsecret in gke-connectnamespace with a new service account key file, run the following command:creds-gcpkubectl delete secret creds-gcp -n gke-connect
kubectl create secret generic creds-gcp -n gke-connect--from-file=creds-gcp.json=/path/to/file
- Workload Identity
--enable-workload-identity- Enable Workload Identity when registering the cluster with a fleet. Ensure thatGKE Workload Identity is enabled on your GKE cluster, it is a requirement forusing Workload Identity with memberships. Refer to the
Enable GKE WorkloadIdentitysection inhttps://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity#enable--service_account_key_file flag should not be set if this is set.This flag argument must be specified if any of the other arguments in this groupare specified.
- At most one of these can be specified:
--has-private-issuer- Set to true for clusters where no publicly-routable OIDC discovery endpoint forthe Kubernetes service account token issuer exists.
When set to true, the gcloud command-line tool will read the private issuer URLand JSON Web Key Set (JWKS) (public keys) for validating service account tokensfrom the cluster's API server and upload both when creating the Membership.Google Cloud Platform will then use the JWKS, instead of a public OIDC endpoint,to validate service account tokens issued by this cluster. Note the JWKSestablishes the uniqueness of issuers in this configuration, but issuer claimsin tokens are still compared to the issuer URL associated with the Membershipwhen validating tokens.
Note the cluster's OIDC discovery endpoints (KUBE-API-ADDRESS/.well-known/openid-configuration andKUBE-API-ADDRESS/openid/v1/jwks) must still benetwork-accessible to the gcloud client running this command.
--public-issuer-url=PUBLIC_ISSUER_URL- Skip auto-discovery and register the cluster with this issuer URL. Use thisoption when the OpenID Provider Configuration and associated JSON Web Key Setfor validating the cluster's service account JWTs are served at a publicendpoint different from the cluster API server. Requires--enable-workload-identity.
- 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 helpfor details. - NOTES
- This command is currently in beta and might change without notice. Thesevariants are also available:
gcloudcontainerhubmembershipsregistergcloudalphacontainerhubmembershipsregister
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.