Google Cloud

How to Create a virtual machine using the GCP command line

How to Create a virtual machine using the GCP command line

hello friends today i am gone to teach you how you can Create a virtual machine using the GCP command line.

Some Basic Steps

  • Login to Your GCP Account Click here
  • To open GCP console, 
  • On Navbar, click on Icon to Open Cloud Shell button.
  • Ones its open it can ask for permission
  • Click Continue…
 
 

First we need to Know Zones and Region is default setup right now.

  • To display a list of all the zones in the region to which Qwiklabs assigned you, enter this partial command gcloud compute zones list | grep followed by the region that Qwiklabs or your instructor assigned you to.</span >

 

Your completed command will look like this:

  • gcloud compute zones list | grep us-central1</span >
 

To set your default zone to the one you just chose, enter this partial command gcloud config set compute/zone followed by the zone you chose.

Your completed command will look like this:

  • gcloud config set compute/zone us-central1-b</span >
 
 
To create a VM instance called my-vm-2 in that zone, execute this command:

Your completed command will look like this:

gcloud compute instances create “my-vm-2” 
–machine-type “n1-standard-1” 
–image-project “debian-cloud”
–image “debian-9-stretch-v20190213” 
–subnet “default”</span >

Note: The VM can take about two minutes to launch and be fully available for use.

——————————————————————————————————————————————–</i ></span >

Create VM instance with Your name

Some Basic Steps

  • Login to Your GCP Account Click here
  • To open GCP console, 
  • On Navbar, click on Icon to Open Cloud Shell button.
  • Ones its open it can ask for permission 
  • Click Continue…
 

To display a list of all the zones in the region to Run This command.

Your completed command will look like this:

  • gcloud compute zones list | grep </span >enter you zone name

Choose a zone from that list.
After Choosing zone name.

 
Your completed command will look like this:
  • gcloud config set computeenter you zone name
 
 

To create a VM instance called ( sachin ) in that zone, execute this command</span >

Your completed command will look like this:
 
gcloud compute instances create “sachin” 
–machine-type “n1-standard-1″ 
–image-project “debian-cloud” 
–image “debian-9-stretch-v20190213″ 
–subnet “default”
 
Note: The VM can take about two minutes to launch and be fully available for use.

Important Points…

In first Line </span >

  • gcloud compute instances create “Sachin”</span >  your project name.</span >

In Second Line 

  • –machine-type “n1-standard-1″</span >  Specify machine Type.</span >

In Third Line 

  • –image-project “debian-cloud” </span > Specify Project.</span >

In Fourth Line 

  • –image “debian-9-stretch-v20190213″</span >  Specify OS.</span >

 

——————————————————————————————————————————————–</i ></span >

Hit Enter..

Now your VM Instance taking two minutes to ready…