Cloud Computing
Name – Abhishek Bhausaheb Gangurde
Aim - Create a Virtual Machine in using GCP cloud skill boost.
Platform – Google Cloud Platform (Google cloud skill boost)
Introduction - Google Compute Engine enables users to create and manage scalable virtual
machines (VMs) on Google Cloud's robust infrastructure. These VMs support a wide range of
operating systems including various Linux distributions (Debian, Ubuntu, SUSE, Red Hat,
CoreOS) and Windows Server. Designed for speed and consistency, Compute Engine allows
for the deployment of thousands of virtual CPUs to meet diverse computing needs.
In this hands-on lab, the focus was on creating VM instances using both the Google Cloud
Console and the gcloud command-line tool within Cloud Shell. Additionally, the lab
demonstrated how to deploy and connect a NGINX web server to a VM, offering a practical
introduction to server setup and management on GCP.
Typing out the commands instead of copying them was encouraged to enhance conceptual
understanding and reinforce the learning experience.
Learning Objectives -
Create a Virtual Machine using the Google Cloud Console.
Create a Virtual Machine using the gcloud command-line tool.
Deploy and configure a NGINX web server on a VM.
Understand the process of connecting a web server to a cloud-based VM.
Setup and requirements -
Step 1) –
Start Lab and use chrome browser recommended
Save credentials for further use
Step 2) –
Click and Open Google Cloud console in the Incognito Window
Choose an account dialog, click use Another Account
Sign in to the user
Step 3) -
Activate Cloud Shell which is at the Top of the Google cloud console
Authorize cloud shell to make Google Cloud API calls
Step 4) –
To list the active account name type this command on the cloud console
gcloud auth list
Step 5) –
You can list the project ID with this command:
gcloud config list project
Step 6) –
Compute Engine Regions and Zones
Certain Compute Engine resources are deployed within specific regions or zones. A region
represents a particular geographical location where Google Cloud resources can operate.
Each region contains one or more zones, which are isolated locations within the region.
For example, the us-central1 region refers to a data centre in the Central United States. This
region includes the following zones:
us-central1-a
us-central1-b
us-central1-c
us-central1-f
Organizing resources by region and zone helps improve availability, latency, and fault
tolerance in cloud deployments.
1. Set the default region for Compute Engine:
gcloud config set compute/region us-east1
2. Create an environment variable for the region:
export REGION=us-east1
3. Create an environment variable for the zone:
export ZONE=us-east1-c
Task 1) –
Create a new instance from the Cloud console
Step 1) –
In the Cloud console, on the Navigation menu (☰), click Compute Engine > VM
Instances.
o Click on Create Instance
o In the Machine Configuration: Enter the fields given to you like below
Step 2) –
After setting the machine configuration, the next step is to configure the operating
system and storage settings for the VM instance.
Click on OS and storage in the VM creation page.
Click Change to begin boot disk configuration.
Set the following values:
Step 3) –
Click Networking.
Firewall: Allow HTTP traffic
This automatically creates a firewall rule to allow HTTP traffic on port 80.
Then click on create
Scroll down and click Create to launch the virtual machine instance.
After creation, the instance gcelab will appear in the VM Instances list on the VM Instances
page.
To connect to the virtual machine using SSH, click the SSH button located to the right of the
instance name.
Task 2) –
Install an NGINX web server
Run this command in the browser
sudo apt-get update
Run the following command to install NGINX:
sudo apt-get install -y nginx
Run the following command to confirm that NGINX is running:
ps auwx | grep nginx
To see the web page, return to the Cloud console and click the External IP link in the row for
your machine, or add the External IP value to http://EXTERNAL_IP/ in a new browser
window or tab.
A default web page should open that says: Welcome to nginx!
Task 3) - Create a new instance with gcloud
Apart from using the Cloud Console, virtual machine instances can also be created using the
command line in Cloud Shell.
To create a new VM instance named gcelab2:
gcloud compute instances create gcelab2 --machine-type=e2-
medium --zone=$ZONE
This command creates a VM with the e2-medium machine type in the zone specified by the
$ZONE environment variable.
Default Configuration of the New Instance
The new instance will have these default settings:
OS: Debian 11 (bullseye)
Machine Type: e2-medium
Boot Disk: Persistent disk with the same name as the instance
To view all defaults, run:
gcloud compute instances create --help
To exit help, press CTRL + C.
Verifying VM Instances
Go to Compute Engine > VM Instances and refresh the page. Your instances (gcelab and
gcelab2) will be listed.
Connecting SSH
To connect to the VM:
gcloud compute ssh gcelab2 --zone=us-central1-c
Press Y to continue and leave the passphrase empty. To disconnect, type:
Exit
Test Knowledge:
You can create a VM instance in Compute Engine through the following ways:
The gcloud command line tool
The Cloud console
So, we have successfully done the creating a Virtual Machine in Google Cloud Platform
Conclusion -
Creating a VM in Google Cloud Platform (GCP) is a straightforward process that can be done
either through the Cloud Console or the gcloud command line tool. The process involves
configuring key settings such as the machine type, operating system, and boot disk. Once the
VM is created, you can verify its status in the VM Instances page and connect to it using SSH.
By setting default regions and zones, you can streamline future deployments. GCP offers
flexibility and scalability, making it an ideal platform for various cloud-based workloads.