Skip to content
Latchkey

gcloud container clusters get-credentials: GKE kubeconfig

Write GKE cluster credentials into kubeconfig so kubectl and helm can target the cluster.

gcloud container clusters get-credentials fetches endpoint and auth data for a GKE cluster and merges it into your kubeconfig. After running it, kubectl uses the gke-gcloud-auth-plugin to authenticate. In CI this is the bridge between gcloud auth and kubectl.

Common flags

  • CLUSTER - the cluster name (positional)
  • --region=REGION or --zone=ZONE - cluster location
  • --project=PROJECT_ID - project that owns the cluster

Example in CI

Fetch credentials, then verify kubectl can reach the cluster.

shell
gcloud container clusters get-credentials prod-cluster \
  --region=us-central1 --project=my-project
kubectl get nodes

Common errors in CI

  • No such file or directory: gke-gcloud-auth-plugin - install the gke-gcloud-auth-plugin component
  • You do not currently have an active account selected - gcloud auth not run first
  • Required "container.clusters.get" permission ... denied - SA missing roles/container.viewer

Key takeaways

  • Merges GKE credentials into kubeconfig for kubectl and helm to use.
  • Requires gke-gcloud-auth-plugin to be installed on the runner.
  • Provide --region or --zone; clusters are not found without the right location.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →