Last active
December 28, 2021 15:12
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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