In order e.g. to get the number of nodes in a GKE cluster, you need to:
- use
glcoud
command to switch to the appropriate project - use
gcloud
command to get the credentials for the cluster in the likes of
gcloud container clusters get-credentials "${CLUSTER_NAME}" --zone "${ZONE}" --project "${PROJECT_ID}"
(but after explicitly passing the zone)
Assuming I am powerful enough, is there a way to get e.g. the number of nodes for a GKE cluster just by iterating over the projects and then the clusters, e.g.
for project in gcp_projects:
clusters = get_clusters(project)
for cluster in clusters:
nodes = get_number_of_nodes(cluster)