gcloud container hub memberships get-credentials (MEMBERSHIP_NAME : --location=LOCATION) [GCLOUD_WIDE_FLAG …]
kubeconfig file with the appropriate credentials and endpoint
information to send kubectl commands to a fleet-registered and
-connected cluster through the Connect Gateway service.
It takes a project, passed through by set defaults or flags. By default,
credentials are written to $HOME/.kube/config. You can provide an
alternate path by setting the KUBECONFIG environment variable. If
KUBECONFIG contains multiple paths, the first one is used.
Upon success, this command will switch the current context to the target cluster
if other contexts are already present in the kubeconfig file.
To force the use of Application Default Credentials (ADC) for authentication,
you can set the container/use_application_default_credentials
property to true:
gcloud config set container/use_application_default_credentials truegcloud container hub memberships get-credentials my-clustergcloud container hub memberships get-credentials my-cluster --location=global
Get the Gateway kubeconfig for a cluster registered in us-central1:
gcloud container hub memberships get-credentials my-cluster --location=us-central1
To set the project attribute:
MEMBERSHIP_NAME on the command line with a
fully specified name;
--project on the command line;
core/project.
MEMBERSHIP_NAME
To set the membership attribute:
MEMBERSHIP_NAME on the command line.
--location=LOCATIONus-central1. If not
specified, attempts to automatically choose the correct region.
To set the location attribute:
MEMBERSHIP_NAME on the command line with a
fully specified name;
--location on the command line;
gkehub/location.
--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.
gcloud alpha container hub memberships get-credentialsgcloud beta container hub memberships get-credentials
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-27 UTC.