Google Certified Associate Cloud Engineer 2020

Sign Up Free or Log In to participate!

how does it choose the manual zone?

how does it choose the manual zone?

3 Answers

You can specify the zone/region with gcloud command using --zone or --region switch.

Hey folks,

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   104.196.47.240  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?

Thanks!!

-Bianchi

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.

_https://cloud.google.com/compute/docs/regions-zones/changing-default-zone-region#how_a_default_region_and_zone_affect_your_project_

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.

-Bianchi

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?