gcloud container clusters get-credentials: CI Errors
Point kubectl at a GKE cluster by fetching its credentials.
gcloud container clusters get-credentials writes a kubeconfig entry for a GKE cluster so kubectl can connect, using the gke-gcloud-auth-plugin to mint tokens from your gcloud identity.
What it does
The command adds a cluster/user/context to ~/.kube/config for the named GKE cluster. The user entry uses gke-gcloud-auth-plugin (an exec credential plugin) to obtain tokens, so kubectl authenticates as your active gcloud account. You must specify the cluster’s location with --region or --zone.
Common usage
# Get credentials for a regional cluster
gcloud container clusters get-credentials my-cluster \
--region us-central1 --project my-project
# Zonal cluster
gcloud container clusters get-credentials my-cluster \
--zone us-central1-a
kubectl get nodesCommon error in CI: "gke-gcloud-auth-plugin ... not found" / no location
kubectl fails with "exec: gke-gcloud-auth-plugin: executable file not found in $PATH" because the auth plugin is a separate component, or get-credentials errors that it cannot find the cluster when --region/--zone is missing. Fix: install the plugin (gcloud components install gke-gcloud-auth-plugin, or apt-get install google-cloud-cli-gke-gcloud-auth-plugin) and ensure it is on PATH before kubectl runs; always pass the correct --region (regional) or --zone (zonal) matching how the cluster was created.
Key options
| Option | Purpose |
|---|---|
| CLUSTER_NAME | Required cluster name |
| --region | Regional cluster location |
| --zone | Zonal cluster location |
| --project | Project containing the cluster |
| --internal-ip | Use the cluster’s private endpoint |