Google Cloud Compute Engine - Full Tutorial
Google Compute Engine - Full Tutorial
Google Cloud Compute Engine (GCE) is Google's IaaS platform that allows users to create and manage virtual
machines.
Core Concepts:
- VM Instance: Virtual machine in GCP
- Machine Type: Defines the CPU and memory
- Boot Disk: Disk to boot the VM
- Image: OS and configuration used to launch VMs
- Persistent Disk: Additional storage attached to VM
- Startup Script: Script that runs at VM boot
- Preemptible VMs: Low-cost, short-lived VMs
Creating VMs:
1. Console: Navigate to Compute Engine > VM instances and create a VM.
2. gcloud CLI:
gcloud compute instances create my-vm --zone=us-central1-a --machine-type=e2-medium --image-family=debian-11
--image-project=debian-cloud
3. Terraform: Use resource "google_compute_instance" to define infrastructure.
Networking:
- Use tags (http-server) and firewall rules to allow access.
- gcloud compute firewall-rules create allow-http --allow tcp:80 --target-tags=http-server
Pricing:
- Sustained Use Discounts: For VMs used long-term
- Preemptible VMs: Cheaper, max 24 hours
- Committed Use Discounts: Discounts for 1-3 year commitment
Useful gcloud Commands:
- gcloud compute instances list
- gcloud compute ssh my-vm
- gcloud compute instances stop/start/delete my-vm
Best Practices:
- Use labels and metadata
- Use snapshots and images for backups
- Use Managed Instance Groups for scaling
Exam Tip:
Know how to create/manage VMs, allow traffic via firewall, and use startup scripts and snapshots.
Page 1