Introduction
Google Compute Engine (GCE) is a core service of Google Cloud Platform (GCP) that provides scalable, high-performance virtual machines (VMs) running in Google's data centers. Compute Engine allows you to create and manage VMs, configure networking, and manage storage.
Key Concepts
-
Virtual Machines (VMs):
- VMs are the fundamental building blocks of Compute Engine. They are virtualized instances of physical computers.
- VMs can run various operating systems, including Linux and Windows.
-
Machine Types:
- Predefined machine types: Standard configurations provided by GCP.
- Custom machine types: Allows you to specify the number of vCPUs and memory.
-
Persistent Disks:
- Durable storage options that can be attached to VMs.
- Types include Standard Persistent Disks, SSD Persistent Disks, and Local SSDs.
-
Images:
- Pre-configured templates for VM instances.
- Can be public images provided by GCP or custom images created by users.
-
Snapshots:
- Point-in-time backups of persistent disks.
- Useful for data recovery and creating new disks.
-
Instance Groups:
- Managed instance groups: Automatically manage a group of identical VMs.
- Unmanaged instance groups: Manually manage a group of VMs.
Setting Up a Compute Engine VM
Step-by-Step Guide
-
Navigate to Compute Engine:
- Go to the GCP Console.
- Select "Compute Engine" from the navigation menu.
-
Create a New VM Instance:
- Click on "Create Instance".
- Fill in the necessary details:
- Name: Give your VM a unique name.
- Region and Zone: Select the geographical location for your VM.
- Machine Type: Choose a predefined machine type or create a custom one.
- Boot Disk: Select an operating system image or use a custom image.
- Firewall: Configure firewall rules to allow HTTP/HTTPS traffic if needed.
-
Configure Networking:
- Select the network and subnetwork for your VM.
- Optionally, assign a static IP address.
-
Create the VM:
- Click "Create" to launch your VM instance.
Example
gcloud compute instances create my-vm-instance \ --zone=us-central1-a \ --machine-type=e2-medium \ --subnet=default \ --image=debian-10-buster-v20200910 \ --image-project=debian-cloud \ --boot-disk-size=10GB \ --boot-disk-type=pd-standard \ --boot-disk-device-name=my-vm-instance
Explanation
gcloud compute instances create my-vm-instance
: Command to create a new VM instance namedmy-vm-instance
.--zone=us-central1-a
: Specifies the zone where the VM will be created.--machine-type=e2-medium
: Specifies the machine type.--subnet=default
: Uses the default subnet.--image=debian-10-buster-v20200910
: Specifies the image to use for the boot disk.--image-project=debian-cloud
: Specifies the project that contains the image.--boot-disk-size=10GB
: Sets the boot disk size to 10GB.--boot-disk-type=pd-standard
: Uses a standard persistent disk.--boot-disk-device-name=my-vm-instance
: Names the boot disk.
Practical Exercise
Task
Create a VM instance using the GCP Console with the following specifications:
- Name:
test-vm
- Region:
us-west1
- Zone:
us-west1-b
- Machine Type:
n1-standard-1
- Boot Disk: Ubuntu 18.04 LTS
- Allow HTTP and HTTPS traffic
Solution
- Navigate to the GCP Console.
- Select "Compute Engine" from the navigation menu.
- Click "Create Instance".
- Fill in the details:
- Name:
test-vm
- Region:
us-west1
- Zone:
us-west1-b
- Machine Type:
n1-standard-1
- Boot Disk: Click "Change" and select "Ubuntu 18.04 LTS".
- Firewall: Check "Allow HTTP traffic" and "Allow HTTPS traffic".
- Name:
- Click "Create" to launch the VM.
Common Mistakes and Tips
- Incorrect Zone Selection: Ensure the selected zone supports the desired machine type and resources.
- Firewall Rules: Remember to configure firewall rules to allow necessary traffic.
- Persistent Disk Size: Choose an appropriate disk size based on your application needs.
Conclusion
In this section, you learned about Google Compute Engine, its key concepts, and how to create and manage VM instances. You also practiced creating a VM instance using both the GCP Console and the gcloud
command-line tool. Understanding Compute Engine is fundamental for leveraging GCP's infrastructure capabilities. Next, we will explore Cloud Storage, another essential service in GCP.
Google Cloud Platform (GCP) Course
Module 1: Introduction to Google Cloud Platform
- What is Google Cloud Platform?
- Setting Up Your GCP Account
- GCP Console Overview
- Understanding Projects and Billing
Module 2: Core GCP Services
Module 3: Networking and Security
Module 4: Data and Analytics
Module 5: Machine Learning and AI
Module 6: DevOps and Monitoring
- Cloud Build
- Cloud Source Repositories
- Cloud Functions
- Stackdriver Monitoring
- Cloud Deployment Manager
Module 7: Advanced GCP Topics
- Hybrid and Multi-Cloud with Anthos
- Serverless Computing with Cloud Run
- Advanced Networking
- Security Best Practices
- Cost Management and Optimization