DEV Community

Cover image for Part-49: 🌐 Google Cloud VPC – Auto Mode vs Custom Mode (with VM Deployment)
Latchu@DevOps
Latchu@DevOps

Posted on

Part-49: 🌐 Google Cloud VPC – Auto Mode vs Custom Mode (with VM Deployment)

In this guide, we’ll explore how to create and use Auto-mode and Custom-mode VPC networks in Google Cloud. We’ll also launch a VM instance in a custom subnet and verify.


βœ… Step-01: Introduction

We will perform the following steps:

  1. Create Auto Mode VPC Network
  2. Create Custom VPC Network
  3. Create Subnet in Custom VPC Network
  4. Launch a VM instance inside the custom subnet with a webserver startup script
  5. Verify deployment
  6. Clean-Up resources

βœ… Step-02: Understand Default VPC Network

  • Navigate to VPC Network β†’ default.
  • Notice that default subnets are pre-created and ready to use in all regions.

βœ… Step-03: Auto Mode VPC Network

Step-03-01: Create Auto Mode VPC

v1

  • Go to VPC Network β†’ CREATE VPC NETWORK
  • Name: vpc1-auto
  • Description: Automode VPC
  • Subnets: Automatic
  • Firewall Rules:
allow-custom (internal access)
allow-icmp
allow-rdp
allow-ssh
Enter fullscreen mode Exit fullscreen mode

v2

  • Dynamic Routing Mode: Regional (default)
  • Click CREATE

Step-03-02: Verify Auto Mode VPC

  • Go to vpc1-auto β†’ Subnets
  • Verify that subnets are automatically created in each region.

v3


βœ… Step-04: Custom Mode VPC Network

Step-04-01: Create Custom Mode VPC

v4

  • Go to VPC Network β†’ CREATE VPC NETWORK
  • Name: vpc2-custom
  • Description: Custom-mode-VPC
  • Subnets: Custom
  • Firewall Rules:
allow-ssh
allow-icmp
Enter fullscreen mode Exit fullscreen mode

v5

  • Dynamic Routing Mode: Regional (default)
  • Click CREATE

v6


Step-04-02: Create a Subnet

Go to VPC Networks β†’ vpc2-custom β†’ Subnets β†’ ADD SUBNET

v7

  • Name: mysubnet1
  • Region: us-central1
  • IP Stack: IPv4
  • Subnet Range: 10.225.0.0/20
  • Leave others default β†’ Click ADD

v8

v9


βœ… Step-05: Create VM Instance in Custom Subnet

v10

Using gcloud CLI:

# Set Project 
gcloud config set project PROJECT_ID
gcloud config set project gcp-zero-to-hero-468909

# Create VM in mysubnet1
gcloud compute instances create myvm1 \
    --zone=us-central1-a \
    --machine-type=e2-micro \
    --network-interface=subnet=mysubnet1 

# List Compute Instances (Optional)
gcloud compute instances list   

# Describe Network Details (Optional)
gcloud compute instances describe myvm1 --zone=us-central1-a

# Connect to VM (Optional)
gcloud compute ssh --zone "us-central1-a" "myvm1" --project "gcp-zero-to-hero-468909"

Enter fullscreen mode Exit fullscreen mode

βœ… Step-06: Verify Deployment

  • Confirm that VM is deployed inside vpc2-custom β†’ mysubnet1.
  • Check the internal IP address.
  • If you added a startup script with webserver installation (Apache/Nginx), open the external IP in browser to verify.

v11


βœ… Step-07: Clean-Up

# List Instances
gcloud compute instances list 

# Delete VM
gcloud compute instances delete myvm1 \
    --zone=us-central1-a \
    --delete-disks=all

Enter fullscreen mode Exit fullscreen mode

v12


πŸ”‘ Summary

  • Auto-mode VPC = Google creates subnets in all regions automatically.
  • Custom-mode VPC = You create your own subnets with full control.
  • Always use Custom mode VPC for real workloads.

Top comments (0)