Chương 3: Mô hình VPC của GCP — Kiến Trúc Mạng Ảo Toàn Cầu
Giới thiệu
VPC (Virtual Private Cloud) là nền tảng của mọi thứ trong GCP. Không chỉ là một mạng ảo đơn thuần, VPC là một kiến trúc SDN (Software-Defined Networking) toàn cầu được xây dựng trên Andromeda stack của Google, tích hợp sâu với Jupiter fabric vật lý của GCP.
Chương này tập trung vào các khía cạnh thực chiến của VPC design, từ global-regional consistency, CIDR planning, đến firewall policies phức tạp và multi-tenancy patterns. Chúng ta sẽ phân tích những lỗi phổ biến khiến production systems bị outage, cách nó ảnh hưởng ở scale, và chiến lược phòng tránh.
Tại sao VPC quan trọng ở Scale
- Blast radius: Một nhân sai trong VPC design có thể cách ly toàn bộ tổ chức hoặc chỉ một team
- Performance: VPC routing logic trực tiếp ảnh hưởng đến latency, packet loss, bandwidth
- Security: Firewall rules, peering, shared VPC là cửa ngõ duy nhất vào hệ thống - misconfiguration = data breach
- Cost: Routing decisions ảnh hưởng đến egress costs, bandwidth allocation
- Multi-region complexity: Global VPC + regional subnets = eventual consistency challenges
Quy ước của Chương
- Production-focused: Mọi design pattern được so sánh với constraints thực tế ở scale (10K+ VMs, multi-region)
- Opinionated: Khi có trade-offs, chúng tôi giải thích cách lựa chọn based trên operational experience
- GCP-native: Ưu tiên các GCP-specific solutions (Cloud Router, hierarchical firewall policies) hơn generic approaches
Cấu trúc Chương
Phần 1: VPC Fundamentals (Global-Regional Model)
VPC là Global Resource, Subnet là Regional
- VPC scope vs subnet scope
- Implications cho multi-region
- Tại sao GCP khác với AWS/Azure
- Auto-mode limitations (10.128.0.0/9)
- Custom-mode flexibility
- Tại sao production luôn dùng custom
- Migration từ auto → custom
- Primary vs secondary ranges
- GKE Pod CIDR allocation
- IP address management at scale
- Overlapping ranges constraints
Phần 2: Routing Architecture
- Cơ chế alias IP (không NAT)
- Direct pod-to-pod routing
- Anti-spoofing checks
- Container networking patterns
- Subnet routes (automatic)
- Custom static routes
- Next hop types (instances, ILBs, VPN)
- Route conflicts & resolution
- Cloud Router BGP sessions
- Route learning & advertisement
- Regional vs global mode
- On-premises connectivity patterns
- Default route (0.0.0.0/0)
- Subnet routes
- Special routing paths (GFE, IAP, etc.)
- IAM/KMS/Serverless routes
Phần 3: Firewall & Security
- Stateful inspection
- Priority 0-65535
- Ingress (implied deny) vs egress (implied allow)
- Connection tracking table limits
- Rule evaluation order
Network Tags vs Service Accounts
- Firewall targeting methods
- Tags vs service accounts decision matrix
- Multi-tier tagging patterns
- IAM-integrated security
Hierarchical Firewall Policies
- Policy evaluation order (org → folder → project → VPC)
- Allow/deny semantics
- Exceptions & overrides
- Multi-org scenarios
- Layer 7 filtering capabilities
- FQDN-based rules
- IDS/IPS integration
- Performance implications
Phần 4: Network Connectivity
- No transitivity principle
- Subnet overlap constraints
- Route exchange options
- DNS resolution in peered networks
- Multi-project peering patterns
Shared VPC & Centralized Management
- Host project vs service projects
- Subnet sharing granularity
- IAM role separation
- Multi-tenancy with Shared VPC
- Cost attribution
- 199.36.153.x/30 virtual IPs
- Google APIs routing
- Private vs restricted endpoints
- VPC Flow Logs implications
Phần 5: Observability & Control
- Sampling mechanics
- Metadata fields
- Export destinations
- Cost analysis (sampling heuristics)
- Troubleshooting patterns
- Topology visualization
- Connectivity tests
- Performance insights
- Firewall analysis
VPC Service Controls for Data Protection
- Perimeter boundaries
- Data exfiltration prevention
- Service access policies
- Shared VPC + VPC SC integration
Điều kiện Tiên quyết
- Chương 2 (GCP Physical Network Architecture): Hiểu Andromeda, Jupiter, global backbone
- Networking fundamentals: TCP/IP, CIDR notation, BGP, routing concepts
- GCP fundamentals: Compute Engine, GKE, service accounts, IAM
Mục tiêu Learning
Sau khi hoàn thành chương này, bạn sẽ có khả năng:
- Design VPC networks cho production systems với multi-region, multi-tenant constraints
- Debug connectivity issues sử dụng routing logic, firewall rules, VPC Flow Logs
- Architect Shared VPC setups cho large organizations với cost allocation
- Implement zero-trust networking patterns using hierarchical firewall policies
- Plan IP address allocation cho scale 10K+ resources mà không conflicts
- Optimize costs bằng understanding routing paths, NAT, egress charges
Độ sâu: 5/5
Chương này giả định kiến thức cao về networking. Chúng ta sẽ không explain "what is CIDR" mà tập trung vào "how to allocate CIDRs at GCP scale without conflicts, with rollback scenarios".
Chú ý Đặc biệt
- AWS migration: AWS VPC ≠ GCP VPC. Peering là optional trong AWS, required trong GCP cho multi-VPC
- Azure migration: Azure NSGs không tương đương firewall rules (NSGs chỉ áp dụng VM level)
- On-premises hybrid: Cloud Router + Interconnect khác hoàn toàn so với ExpressRoute
Vui lòng bắt đầu từ section 1 (Global-Regional) để xây dựng mental model chính xác trước khi đi vào advanced patterns.