Perfect! Let me provide a comprehensive solution for anyone facing similar issues with VPC subnet expansion and Private Service Access.
VPC Subnet Expansion Impact:
When you expand VPC subnets, existing firewall rules don’t automatically adapt. You need to explicitly update or create new rules covering the expanded ranges.
Firewall Rule Management Steps:
- List current firewall rules and identify gaps:
gcloud compute firewall-rules list --filter="network=YOUR_VPC" --format="table(name,sourceRanges,allowed)"
- Check Private Service Access allocated ranges:
gcloud services vpc-peerings list --service=servicenetworking.googleapis.com --network=YOUR_VPC
- Create dedicated firewall rule for new subnet:
gcloud compute firewall-rules create allow-db-new-subnet \
--network=YOUR_VPC \
--allow=tcp:5432 \
--source-ranges=10.128.0.0/20 \
--priority=1000
Private Service Access Configuration Best Practices:
• Use CIDR-based firewall rules instead of tag-based targeting for subnet expansions - more flexible and automatic coverage
• Maintain separate firewall rules for Private Service Access traffic (priority 900-1000) vs application traffic (priority 1000-2000)
• Always verify the allocated IP range matches your firewall source ranges
• Document your firewall rule hierarchy and priorities to avoid conflicts
• Test connectivity from all subnets after VPC changes before deploying to production
Priority Guidelines:
- Critical infrastructure (databases): 900-1000
- Application services: 1000-2000
- General access: 2000-3000
- Explicit denies: 100-500 (use sparingly)
Verification:
After updating firewall rules, test from multiple pods/instances in different subnets:
psql -h 10.128.5.42 -U dbuser -d production
Monitor Cloud SQL logs and VPC Flow Logs to confirm traffic is allowed. The key is maintaining explicit allow rules that cover all your subnet ranges, especially after infrastructure changes like VPC expansion.