You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
As your GCP environment grows beyond a single VPC or project, you need ways to connect VPCs together. GCP offers two primary mechanisms: VPC Network Peering for connecting VPCs across projects or organisations, and Shared VPC for sharing a single VPC across multiple projects within an organisation. Each approach has distinct characteristics, use cases, and trade-offs.
VPC Peering creates a direct network path between two VPC networks, allowing resources in each VPC to communicate using internal IP addresses. Traffic between peered VPCs stays on Google's network — it never traverses the public internet.
Peering requires configuration on both sides:
# In project-a: peer vpc-a with vpc-b
gcloud compute networks peerings create peer-a-to-b \
--network=vpc-a \
--peer-project=project-b \
--peer-network=vpc-b
# In project-b: peer vpc-b with vpc-a
gcloud compute networks peerings create peer-b-to-a \
--network=vpc-b \
--peer-project=project-a \
--peer-network=vpc-a
| Limit | Value |
|---|---|
| Peering connections per VPC | 25 (can be increased) |
| Maximum peered group size (total VMs/endpoints) | 15,500 |
By default, only subnet routes are exchanged. To share custom static routes or routes learned via Cloud Router:
gcloud compute networks peerings update peer-a-to-b \
--network=vpc-a \
--export-custom-routes \
--import-custom-routes
Shared VPC allows an organisation to share a single VPC network across multiple service projects. A host project owns the VPC, and service projects deploy resources (VMs, GKE clusters, etc.) into subnets of that shared VPC.
# Enable Shared VPC host project
gcloud compute shared-vpc enable host-project-id
# Attach a service project
gcloud compute shared-vpc associated-projects add service-project-id \
--host-project=host-project-id
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.