Skip to content
Latchkey

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

Terminal
# 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 nodes

Common 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

OptionPurpose
CLUSTER_NAMERequired cluster name
--regionRegional cluster location
--zoneZonal cluster location
--projectProject containing the cluster
--internal-ipUse the cluster’s private endpoint

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →