Objective :

Google Compute Engine is service provided by google which enables running large-scale workloads on virtual machine hosted on google servers.  Although a late comer ( 2012) , google compute engine is giving a tough competition to Amazon EC2 service already. 

Getting Started with compute engine is  fairly easy. In this article , I will show you how to create a  virtual machine , setup basic network firewall rules and then use SSH to login to your virtual machine . 


1) Setup Project in Google Compute Engine 

a) Create A project . 

After  you have signed up for google cloud  goto : 


Click Create Project  : 

On New Project Dialog Box . Choose a Project name and a Project ID . Choose a handy name for project ID because you will need to re use it plenty of times. 

Next is our project dashboard , this is the area we will be performing most of our work on  ( unless you prefer command line over GUI )

Google won’t let you move forward unless you enable billing . 

b) Activate Billing

This is self explanatory. You will need to add your credit card / wallet info to activate billing. 

2)  Create a New Virtual Machine  instance

Name : Choose a name of your choice 

Zones : If you are launching only one instance , zone doesn’t matter much, you can choose one depending on your expected viewership. 

In case of load balancing , choose each instance from difference zone.  

Following zones are available :

Machine Type :

Google offers pre defined configurations ranging from 1 virtual cpu to 16 virtual cpus and ram availability from 3 to 60 GB .  Choose machine type depending on your processing requirements. 

Boot Source: 

For starting New Disk from image will serve the purpose . 

Image : 

Google offers  range of operating system . You have both the options , choose either Free or Paid OS images.  I am a Debian Fan , so for this particular project , I will go with Debian. 

Network:  choose default

External IP : Ephemeral IP will be temporary , you can opt for a static ip , it makes more sense. It can also be re-used later , in case you decide to delete the instance and launch another one , you can still keep the same ip . 

Once you click on Create , you will be redirected to dashboard and your instance will be created within a minute. 

3) Attach an additional Hard Disk

If you notice in the previous screen shot , there are 2 disks . We only selected one image ( Debian ) for startup . 

I attached another disk  for data , let’s quickly take a look at how to create and attach a disk with a google compute engine instance . 

Click on Compute Engine -> Disks 

Click on NEW DISK 

The options are straight forward : 

Choose a name and description . Description is for your own self. 

Just like you chose zone for instance , select zone for disk . I will suggest choose disk to be in same zone as of your instance. 

Source Type:  It can be an image ( Debian , Centos etc) , snapshot or a blank disk . Since we already have a startup image  and we need this disk for data . We can go with a blank disk . We will then format and mount it in next step . 

Size : If you do not select a size , it defaults to 10 GB . Google recommends minimum size of 200 GB for it . I will go with 1000 GB . 


4) Accessing Virtual Machine via SSH

Web console enables you to create and manage instances, hard disks and firewalls .Any operations on the instance itself must be done via ssh . 

Google provides a very handy tool for accessing the instances : gcutil 

Although you can access your instance using normal ssh clients ( putty etc ) , it’s highly recommended to use gcutil . 

For the sake of understanding , ssh access can be divided into three steps ( for first time users ) 

1) Installing Gcutil :

Since I am a mac user , I will quickly give an overview of installing it on mac . 

a) Start Terminal . ( Finder -> Terminal )

b) Download Cloud SDK :

$ curl https://dl.google.com/dl/cloudsdk/release/install_google_cloud_sdk.bash | bash

c) Restart your terminal . 

2) Authenticating your local system to google cloud 

Google compute engine uses OAUTH2 to authenticate access . Before using gcutil , you must authorize cloud SDK to access your project . 

$ gcloud auth login

This command will open your browser and will ask you to allow permission . Once permissions are granted , you are all set. 

5) Add Firewall Rules : 

Firewall rules can be added from command line as well as from web . For the sake of simplicity, I will add firewall rules from web console . 

on the left menu , Click on Compute Engine -> Networks 

Click on default network 

You will see some default rules added for ssh and internal entries . 

Click on Create New 

I added a new firewall rule for FTP , port 21 : Here’s how it looks : 

Name : anything easy to remember. 

Source IP Ranges : specified which IP addresses should be allowed to access traffic on this port . means everyone is allowed . 

Protocol & ports : If it’s a single port, you can give it as protocol:port , if there’s a range , you can give it as protocol:port1-port5 .  

This is primarily it, you can ssh into the virtual machine and use command lines to install apache / mysql / nginx etc. to create your perfect startup /enterprise  server .