Skip to content

Instantly share code, notes, and snippets.

@JoelPM
Created June 20, 2019 16:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoelPM/f921408ab3dd15492f443ddabe2ffc74 to your computer and use it in GitHub Desktop.
Save JoelPM/f921408ab3dd15492f443ddabe2ffc74 to your computer and use it in GitHub Desktop.
A small script for getting cluster credentials for all GKE clusters in the given GCP projects.
#/bin/sh
# Usage: ./get_all_gcp_cluster_creds.sh PROJECT1 [PROJECT2 ...]
for project in "$@"
do
echo "Getting cluster credentials for project $project"
gcloud container clusters list --project $project --format="table[no-heading](name,location)" | while read cluster location
do
gcloud container clusters get-credentials $cluster --project $project --region $location
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment