☁️ VPC Network
☁️ VPC Network — Simple Notes
1. What is a VPC?
VPC (Virtual Private Cloud) is a virtual version of a physical network inside Google Cloud.
Think of it like your company's private network in the cloud.
It provides connectivity for:
- Compute Engine VM instances
- Google Kubernetes Engine (GKE) clusters
- App Engine Flexible
- Other Google Cloud services that use Compute Engine VMs
Simple example:
Google Cloud │ ┌────▼────┐ │ VPC │ └────┬────┘ ┌──────────┼──────────┐ ▼ ▼ ▼ VM VM GKE
2. VPC and Load Balancing
VPC supports Google's internal networking and load-balancing systems.
It can provide:
- Internal pass-through Network Load Balancers
- Internal proxy-based Application Load Balancers
- Connectivity for external load balancers to their backend services
Think:
Users │ ▼ External Load Balancer │ ▼ VPC Network │ ├── VM 1 ├── VM 2 └── VM 3
3. Connecting VPC to On-Premises Network
Your company may have servers in its own data center (on-premises).
VPC can connect Google Cloud to that network using:
- Cloud VPN → encrypted connection over the internet
- Cloud Interconnect → dedicated/private connection
Simple picture:
Company Data Center │ │ VPN / Interconnect │ ▼ Google Cloud VPC │ ▼ VMs
🛣️ 4. Routes in a VPC
A route tells Google Cloud:
"Where should this packet go?"
Every VPC automatically has routes that allow VMs to communicate with each other, even when the VMs are in different subnets.
Example:
Subnet A 10.1.0.0/24 │ │ route ▼ Subnet B 10.2.0.0/24
A VM in 10.1.0.0/24 can route traffic to a VM in 10.2.0.0/24.
Default Internet Route
A VPC also has a default route that sends traffic destined outside the VPC toward the internet gateway.
Conceptually:
VM │ ▼ VPC Route │ ├── Internal destination → another VM/subnet │ └── External destination → Internet
⭐ 5. Custom Routes
The default routes handle most normal requirements.
But you can create custom/special routes when you need different traffic behavior.
For example:
VM │ ▼ Custom Route │ ▼ Specific Next Hop
Important ⚠️
Creating a route does NOT automatically mean the traffic will be accepted.
You also need an appropriate firewall rule.
Remember:
Route = Where should the packet go?
Firewall = Is the packet allowed?
Both may be required.
🔥 6. Firewall Rules
Firewall rules control whether network traffic is allowed or denied.
Default VPC Network
The default network comes with preconfigured firewall rules that allow instances in the network to communicate with each other.
Custom VPC Network
If you manually create a custom-mode VPC, those default firewall rules are not automatically created.
So you need to create the required firewall rules yourself.
This is one reason custom VPCs require more planning.
🏢 7. Multiple VPC Networks in One Project
A single Google Cloud project can contain multiple VPC networks.
Example:
Project │ ├── production-vpc │ ├── development-vpc │ └── testing-vpc
Each VPC can have its own subnets, routes and firewall configuration.
🌎 8. Default Network and Auto Mode
Normally, when a new Google Cloud project is created, it starts with a default VPC network in auto mode, unless an organization policy prevents this.
Auto Mode VPC
An auto-mode VPC automatically creates one subnet in each Google Cloud region.
For example:
Auto Mode VPC │ ├── us-east4 subnet ├── asia-east1 subnet ├── europe-west1 subnet ├── ... └── other regions
This is convenient when you're learning Google Cloud because you don't need to manually create every subnet.
⭐ 9. Auto Mode vs Custom Mode
| Feature | Auto Mode | Custom Mode |
|---|---|---|
| Subnets | Automatically created | You create them |
| One subnet per region | Yes | No |
| Control | Less | More |
| Good for learning | ✅ Yes | ✅ |
| Production planning | Usually less suitable | ✅ Common choice |
Best Practice
Google recommends using custom-mode VPC networks when you need control over which regions contain subnets.
Instead of automatically getting:
Subnet in every region
you can choose only what you need:
My Custom VPC │ ├── asia-south1 subnet └── us-east4 subnet
This gives you better control over your network design.
🧠 Remember These 7 Points
- VPC = Virtual network in Google Cloud.
- VPC provides connectivity for VMs, GKE, App Engine Flexible, etc.
- Routes decide where traffic goes.
- Firewall rules decide whether traffic is allowed.
- A route alone doesn't guarantee successful communication.
- Auto mode automatically creates a subnet in every region.
- Custom mode lets you choose exactly which regions/subnets you need and is generally the preferred approach for planned environments.
🔑 One-line memory trick
VPC = Network, Subnet = IP range, Route = Path, Firewall = Permission.
Comments
Post a Comment