Introduction to Google Compute Engine

Compute Engine allows you to create a Virtual Machine on Googe Cloud Platform. If you have worked on AWS, it’s similar to the EC2 console, where you create a Virtual machine with your required configurations. With Compute Engine, you can choose the OS system from Public images provided by Google or create or import your Private Image to run. Other features come with Compute Engine, and we will discuss some of them while configuring a Virtual Machine.

What are different ways to create Compute Instances?

Let’s get started! You can create Compute Instances using Google Cloud Console(UI), gcloud command line, and API. On this page, I will create compute Engine using UI and command line.

1. In the Google Cloud Navigation Menu, select Compute Engine. I will see the option to create Compute Engine on the top bar.

2. I will create a new Compute instance, so I will select New VM Instance. We will discuss other options in the coming posts.

3. After selecting New VM Instance, I need to fill in other details. First of all, I will provide a name to the instance, and naming will help us differentiate if you run multiple instances inside the project. You don’t want to login into each VM to identify what they are doing, so it’s a good idea to give a name that will help you remember its use case. After that, I will select my instance’s region and availability zone. For example, you will run a web server that will be accessed by people in India, then you may want to choose a region near your consumers to decrease latency.

4. Now, it’s time to select Machine Configuration that is how much RAM and virtual CPU will be used by your VM instance. I will need to choose the machine family, series, and type for this. These settings provide you a predefined set of hardware resources to deploy the VM. You can select these options as per your workload. With the General Purpose family, all series also allows you to choose custom values as per your requirement. If you require GPU, it’s supported in general-purpose N1 VMs or accelerator-optimized A2 VMs. If you need to select GPU type, you can also choose machine family “GPU.” In my case, I don’t have any special requirements, so I will choose a General Purpose family, N1 series, and n1-standard-1 machine type.

You can see the number at the end for most machine types(e.g., n1-standard-1); it’s the number of vCPUs available in this machine type, and you can see it in UI.

5. I will leave some of the configurations default, and now I will configure the boot disk. In the Boot disk section, I can choose which operating system I will use with disk type and size. By default, Debian GNU/Linux is selected with New balanced persistent disk.

However, you can click on “Change” to select the configuration per your need. In my case, I will choose Ubuntu 18.04 with a Balanced persistent disk where disk size is 20GB. We will review these disk options in our future posts to understand their use case. You can also see other options such as CUSTOM IMAGES, SNAPSHOT, and EXISTING DISK and will learn about these options with their use case in our future posts.

There is an option “Deletion Rule” in the advance configuration that you may want to review. This is really helpful if you’re keeping your data secure from accidental VM deletion. If you delete the VM, the default rule says to delete the boot disk. However, you can select the “keep the disk” option, which will not delete the boot disk if your instance gets deleted, and you can create a new VM from this exiting disk. There are other options that you will learn in other posts.

5. I will leave the Identity and API access option default for now, and we will learn this more during IAM roles for Compute Engine. Please be aware that the default option provides read-only access to Storage and Service Management, write access to Stackdriver Logging and Monitoring, read/write access to Service Control.

6. If you are deploying a public web server, you can select the below options as well, and it will create a firewall rule to allow HTTP and HTTPS access from everywhere.

I will leave other options such as networking and Disk to default. We will look deep into these sections in our future posts. After selecting all the configurations, you can also see Monthly estimate charges on the top right screen. Now I will click create, and the GCP console will create a VM with the selected configuration. Billing charges are going to start after I click to make.

You can see my VM is ready, and I can SSH into the VM by clicking SSH. If you create VM for testing, you can terminate the instance once the testing is done to avoid further charges.

Below is the command-line example I use to create a compute instance through the shell or Cloud SDK. All other options default value will be selected except zone and Machine type. Please be aware that zone value is required to create VM through the command line.

gcloud compute instances create intsnace1 --zone=asia-south1-b --machine-type=n1-standard-1

I hope you now know how to create a basic Compute Instance and if you have any questions, please ask in the comments section.

One Reply to “Introduction to Google Compute Engine”

Leave a Reply

Your email address will not be published. Required fields are marked *