Obtain GKE Basic Auth Credentials and use them
✓ Published0🌍 Public
Aankuagar
Last edited Jul 23, 2019
Created on Oct 31, 2020
This example demonstrates how to obtain GKE basic authentication credentials from a cluster’s metadata and use them to construct a kubeconfig file for subsequent kubectl commands. The script fetches the cluster metadata via `gcloud container clusters describe`, then uses `jq` to extract the CA certificate, endpoint, and password. It writes a kubeconfig file with the admin username and password, then runs `kubectl get clusterroles` against that config to verify access. The code relies on the Google Cloud CLI and `jq` for JSON parsing.
AI-generated description