Get GKE credentials for kubeconfig

Add a GKE cluster to kubeconfig; since Kubernetes 1.26 you need gke-gcloud-auth-plugin in PATH.

gcloud container clusters get-credentials <cluster> --region <id> --project <id>

tool
gcloud8 commands
tags
gcloudk8scloud

More gcloud commands

  • gcloud compute instances list --format="table(name,status,EXTERNAL_IP)" --filter="status=RUNNING"

    Print your own table of running VMs and their public IPs using --format and --filter.

  • gcloud projects get-iam-policy <id> --flatten="bindings[].members" --format="table(bindings.role,bindings.members)"

    Check who has which role; --flatten turns nested bindings into one row per member.

  • gcloud logging read 'severity>=ERROR' --limit 20 --freshness=1h --format='value(timestamp,resource.type,textPayload)'

    Get errors from the last hour across the project; --freshness keeps the query from scanning old logs.

  • gcloud compute ssh <name> --zone <id> --tunnel-through-iap

    Reach a VM without a public IP through Identity-Aware Proxy, no bastion host needed.

  • gcloud secrets versions access latest --secret=<name> --project <id>

    Print the latest Secret Manager version to stdout; in CI, pin a specific version so builds are repeatable.

all 8 gcloud commands