'gcloud get region name from inside GKE workload

Is it possible to get current region information from inside a workload on GKE?

It's an alpine instance, specifically gcr.io/google.com/cloudsdktool/cloud-sdk:357.0.0-alpine and there is no curl or wget and there's no way to install it.



Solution 1:[1]

Your GKE cluster use Compute Engine to run the workload. By the way, you can use the metadata server to get the zone information. When you have the zone, remove the 2 last characters and you have the region!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 guillaume blaquiere