Does anyone know how to connect a local instance of kubectl
to a Google Kubernetes Engine (GKE) cluster, without using the gcloud
tool locally?
The easiest way to achieve this is by copying the ~/.kube/config
file (from a gcloud authenticated instance) to this directory $HOME/.kube
in your local instance (laptop).
But first, and using the authenticated instance, you would have to enable legacy cluster per this document by running these commands:
gcloud config set container/use_client_certificate True
export CLOUDSDK_CONTAINER_USE_CLIENT_CERTIFICATE=True
Then execute the get-credentials
command, and copy the file.
gcloud container clusters get-credentials NAME [--zone=ZONE, -z ZONE] [GCLOUD_WIDE_FLAG …]
Note that you may have to run the get-credentials
command, and copy the config file every time authentication tokens (saved in the config file) expire.