gcloud container hub memberships register

NAME
gcloud container hub memberships register - register a cluster with Hub
SYNOPSIS
gcloud container hub memberships register CLUSTER_NAME --service-account-key-file=SERVICE_ACCOUNT_KEY_FILE (--gke-cluster=LOCATION/CLUSTER_NAME     | --gke-uri=GKE_URI     | [--context=CONTEXT : --kubeconfig=KUBECONFIG]) [--manifest-output-file=MANIFEST_OUTPUT_FILE] [--proxy=PROXY] [GCLOUD_WIDE_FLAG]
DESCRIPTION
This command registers a cluster with the Hub by:
  1. Creating a Hub Membership resource corresponding to the cluster.
  2. Adding in-cluster Kubernetes Resources that make the cluster exclusive
     to one Hub.
  3. Installing the Connect Agent into this cluster.

A successful registration implies that the cluster is now exclusive to a single Hub.

For more information about Connect Agent, go to: https://cloud.google.com/anthos/multicluster-management/connect/overview/

To register a non-GKE or GKE On-Prem cluster use --context flag (with an optional --kubeconfig flag).

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

In all cases, the Connect Agent that is installed in the target cluster must authenticate to Google using a --service-account-key-file that corresponds to a service account that has been granted gkehub.connect permissions.

If the cluster is already registered to another Hub, the registration is not successful.

Rerunning this command against the same cluster with the same CLUSTER_NAME and target GKEHub is successful and upgrades the Connect Agent if a new agent is available.

POSITIONAL ARGUMENTS
CLUSTER_NAME
The membership name that you choose to uniquely represents the cluster being registered on the Hub.
REQUIRED FLAGS
--service-account-key-file=SERVICE_ACCOUNT_KEY_FILE
The JSON file of a Google Cloud service account private key. This service account key is stored as a secret named creds-gcp in gke-connect namespace. To update the creds-gcp secret in gke-connect namespace with a new service account key file, run the following command:

kubectl delete secret creds-gcp -n gke-connect

kubectl create secret generic creds-gcp -n gke-connect --from-file=creds-gcp.json=/path/to/file

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 for e.g us-central1-a/my-cluster.
--gke-uri=GKE_URI
The URI of the GKE cluster; for example, 'https://container.googleapis.com/projects/my-project/locations/us-central1-a/clusters/my-cluster' The URI can obtain by calling: gcloud container clusters list --uri This is only valid if the represented cluster is a GKE cluster. The provided URI will be validated to confirm that it maps to the valid GKE cluster.
Non-GKE cluster identifier.
--context=CONTEXT
The cluster context as it appears in the kubeconfig file. You can get this value from the command line by running command: kubectl config current-context. This flag must be specified if any of the other arguments in this group are specified.
--kubeconfig=KUBECONFIG
The kubeconfig file containing an entry for the cluster. Defaults to $KUBECONFIG if it is set in the environment, otherwise defaults to $HOME/.kube/config.
OPTIONAL FLAGS
--manifest-output-file=MANIFEST_OUTPUT_FILE
The full path of the file into which the Connect Agent installation manifest should be stored. If this option is provided, then the manifest will be written to this file and will not be deployed into the cluster by gcloud, and it will need to be deployed manually.
--proxy=PROXY
The proxy address in the format of http[s]://{hostname}. The proxy must support the HTTP CONNECT method in order for this connection to succeed.
GCLOUD WIDE FLAGS
These flags are available to all commands: --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.

EXAMPLES
Register a non-GKE or GKE On-Prem cluster referenced from a specific kubeconfig file, and install the Connect Agent:
gcloud container hub memberships register my-cluster --context=my-cluster-context --kubeconfig=/home/user/custom_kubeconfig --service-account-key-file=/tmp/keyfile.json

Register a non-GKE or GKE On-Prem cluster referenced from the default kubeconfig file, and install the Connect Agent:

gcloud container hub memberships register my-cluster --context=my-cluster-context --service-account-key-file=/tmp/keyfile.json

Register a non-GKE or GKE On-Prem cluster, and install a specific version of the Connect Agent:

gcloud container hub memberships register my-cluster --context=my-cluster-context --version=gkeconnect_20190802_02_00 --service-account-key-file=/tmp/keyfile.json

Register a non-GKE or GKE On-Prem cluster and output a manifest that can be used to install the Connect Agent:

gcloud container hub memberships register my-cluster --context=my-cluster-context --manifest-output-file=/tmp/manifest.yaml --service-account-key-file=/tmp/keyfile.json

Register a GKE cluster referenced from a GKE URI, and install the Connect Agent:

gcloud container hub memberships register my-cluster --gke-uri=my-cluster-gke-uri --service-account-key-file=/tmp/keyfile.json

Register a GKE cluster referenced from a GKE Cluster location and name, and install the Connect Agent:

gcloud container hub memberships register my-cluster --gke-cluster=my-cluster-region-or-zone/my-cluster --service-account-key-file=/tmp/keyfile.json

Register a GKE cluster, and install a specific version of the Connect Agent:

gcloud container hub memberships register my-cluster --gke-uri=my-cluster-gke-uri --version=gkeconnect_20190802_02_00 --service-account-key-file=/tmp/keyfile.json
gcloud container hub memberships register my-cluster --gke-cluster=my-cluster-region-or-zone/my-cluster --version=gkeconnect_20190802_02_00 --service-account-key-file=/tmp/keyfile.json

Register a GKE cluster and output a manifest that can be used to install the Connect Agent:

gcloud container hub memberships register my-cluster --gke-uri=my-cluster-gke-uri --manifest-output-file=/tmp/manifest.yaml --service-account-key-file=/tmp/keyfile.json
gcloud container hub memberships register my-cluster --gke-cluster=my-cluster-region-or-zone/my-cluster --manifest-output-file=/tmp/manifest.yaml --service-account-key-file=/tmp/keyfile.json
NOTES
These variants are also available:
gcloud alpha container hub memberships register
gcloud beta container hub memberships register