Introduction
In this article, 'll explain how we can create a virtual machine in Google Cloud using the command line tool gcloud which is pre-installed in google cloud shell. Cloud Shell is a Debian-based virtual machine loaded with all the development tools you'll need (gcloud, git, and others) and offers a persistent 5-GB home directory. Let's get started.
Step 1: Open cloud Shell
To open cloud shell, click on the shell icon on the top let corner of the google cloud home page.
Step 2: Authenticate
After clicking on the shell icon, google cloud shell is launched in a terminal window towards the bottom of the home page. Here type 'gcloud auth list' to authenticate your user account to use cloud shell to access and manipulate google cloud resources. You may also type 'gcloud config list project' to check the project you are working under. The term project is analogous to the term organization in AWS.
Step 3: Create virtual machine
Now, we will create our virtual machine using the following command:
gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone us-central1-f
- "compute instances" is the google cloud component we'd like to work with.
- "create" is the action that we'd like to perform.
- gcelab2 is the name of the VM
- "machine-type" defines the CPU/Memory configuration that we would like to use and this is divided into entities called series wherein each series comprises CPU/Memory settings for VMs. In this example we've selected n1-standard-2.
- "zone" attribute specifies the location where the VM will reside.
Step 4: Verify login to the VM
We should now be able see our VM in the VM instances section under the Compute Engine.
You can either click on ssh under the connect section to login to the VM or use the following command in the cloud shell:
gcloud compute ssh gcelab2 --zone us-central1-f
Conclusion
We hope that you found this post to be useful and we look forward towards your feedback and suggestions