Introduction
In this article, we will learn how to set up the first VM in google cloud. We would also learn how to install Apache Server and communicate using external IP Address.
Prerequisites
- Google free tier or paid account.
- Basic knowledge of using Google cloud services and understanding of Virtual Machines in general.
In this article, we will cover the following topics:
- Create a Virtual Machine with Debian public Image
- Understand machine family and configuration
- Install HTTP server and communicate with external environment.
Implementation
Step 1 - Create and configure VM using cloud console
Use this link to create a free tier account https://console.cloud.google.com/
The account creation will require you to provide your credit/debit card details for validation. The first 3 months of the Google cloud Subscription is free and you will not be automatically charged unless you upgrade your account manually.
Once the account is created successfully, we can log into https://console.cloud.google.com/.
The Default google cloud dashbaord would be displayed as below.
A default project would be created. Search for Google compute Engine in Search bar. This would display an option to enable Google Engine API. If you are using compute engine resources for the first time this API needs to be enabled. Click on Enable and wait for some time to get it ready.
Once the compute engine is ready click on create instance. This would open up a new window to configure VM details as below.
Name: Name of virtual machine
Labels: Labels are useful to easily identify and manage VM lists.
Regions and Zones: Select the Region and Zone where the VM needs to be deployed.
Step 2 - Understand machine family and configuration
Machine Configuration: Depending on the type of workflow select the appropriate Machine Type.
Machine Family Types
General Purpose: Hosting general mills web applications select General purpose machine family.
Compute-optimized: Compute intensive workloads like gaming applications can be deployed on this workload.
Memory-Optimized: Memory-intensive workloads like gaming applications can be deployed on this workload.
The number of CPU and memory for a specific machine family can be configured using Machine Type.
Select OS Image
Click on Boot Disk and this would provide options to select from Public Images and our own custom Image. Public Images are managed by google or third party. Custom Images would be our own project Images.
Since we want to communicate with the external environment check HTTP traffic options and click on create. It would take time for the VM instance to be ready.
Once the VM instance is ready it would be displayed under instances.
Step 3 - Install HTTP server and communicate with external environment
External IP Address is used to communicate with resources on this VM from external world. This is the dynamic IP address and it would change when VM is stopped and restarted.
Click on SSH and it would log you into the VM.
Become root user by executing this command.
Pull the latest changes using Debian package manager.
Execute the below command to install apache server
This will install Apache server on our VM.
Click on External IP Adress and it would redirect you to apache page.
Our Apache web server is up and running.
Summary
In this article, we have learned how to work with google compute engine and create and manage our VM in cloud.
In the upcoming articles, we would see in more detail public and private IP address and creating VM using instance templates.
Thanks a lot for reading. I hope you liked this article. Please share your valuable suggestions and feedback. Write in the comment box in case you have any questions. Have a good day!