Google Cloud

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.


Also visit:ย  How to Create Windows VM instance in google cloud


 

How to 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.

 

Your completed command will look like this:

  • gcloud compute zones list | grep us-central1
ย 

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
ย 
ย 
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”

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

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

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ย 

  • gcloud compute instances create “Sachin”

In Second Lineย 

  • –machine-type “n1-standard-1”

In Third Lineย 

  • –image-project “debian-cloud”

In Fourth Lineย 

  • –image “debian-9-stretch-v20190213”

Hit Enter..

Now your VM Instance taking two minutes to ready…