Skip to content

Instantly share code, notes, and snippets.

@davidxia
Last active December 28, 2021 15:12
Show Gist options
  • Save davidxia/1292b0caa96079a7f9c6356c6df38b01 to your computer and use it in GitHub Desktop.
Save davidxia/1292b0caa96079a7f9c6356c6df38b01 to your computer and use it in GitHub Desktop.
Get all credentials of all GKE clusters in a project using fish, gcloud, jq, and xargs
gcloud --project $project container clusters list --format json \
| jq -r '.[] | "\(.name):\(.location)"' \
| xargs -I @ bash -c \
"name=\$(echo @ | cut -d ':' -f 1) \
&& region=\$(echo @ | cut -d ':' -f 2) \
&& gcloud --project $project container clusters get-credentials \$name --region \$region"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment