how does it choose the manual zone?
You can specify the zone/region with
gcloud command using
It’s indeed an interesting question to pursue an answer as I created my first VM some months ago and now I just created another one to execute some tests.
$ gcloud compute instances list NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS myvm us-east1-c n1-standard-1 10.142.0.6 184.108.40.206 RUNNING
It has picked the same zone as before and I don’t really see that set in any configurations I can recall about:
$ gcloud config list --all | grep zone zone (unset) Your active configuration is: [cloudshell-12243] zone (unset)
$ gcloud config list [component_manager] disable_update_check = True [compute] gce_metadata_read_timeout_sec = 5 [core] account = xx disable_usage_reporting = True project = pimballeke-new-project005 [metrics] environment = devshell Your active configuration is: [cloudshell-12243]
$ gcloud config configurations list NAME IS_ACTIVE ACCOUNT PROJECT COMPUTE_DEFAULT_ZONE COMPUTE_DEFAULT_REGION cloudshell-12243 True pimballeke-new-project005
How does it pick a zone when flags as –zone and –region are omitted of the command?
OK, it seems the answer is really what Tuan LE mentioned right above my last message to this thread. I would say that this is something like your account has "default" VPC Network since to very start, when it’s created. So, based on that, docs says:
The default region and zone settings affect only client tools, such as the gcloud command-line tool and the Google Cloud Console. When you use these tools to construct your requests, the tools help you manage resources by automatically selecting the default region and zone.
When you use the Cloud Console to create regional or zonal resources like addresses and instances, Compute Engine sets the region and zone fields for you. You can accept the pre-populated values, or explicitly change one or both of the values.
When you use the gcloud tool, omit setting the –region and –zone flags to use the default region and zone properties for the new project.
You can always change the default region and zone settings in the metadata server, override the default region and zone locally for the gcloud tool, or override the settings manually for each request in either the gcloud tool and the Cloud Console.
I didn’t test, but, I would like to soon remove the default VPC and create another one on another region with some subnets on some zones so that I can create a new VM omitting the –zone and –region.