In Google Cloud Platform (GCP), each new project starts with a default VPC network when you enable the Compute Engine API Unless you disable it.
This makes your use of GCP easier since creating a custom VPC and subnets are not required. But the problem with the default network is that all the auto-created subnets use a set of predefined IPv4 ranges that fit within the 10.128.0.0/9 CIDR block.
Private internal communication is not allowed between projects because of the overlapping network. The limitation applies to both VPC Peering and Cloud VPN services.
This blog shows you how to use Private Service Connect to privately access services running in VM/GKE clusters with overlapping networks. This applies to overlapping networks in the same or different GCP organizations.
Reference Architecture
Target Private Service Connect Setup
Project B is the service producer project and a sample nginx service deployed in a managed instance group instance.
Project A is the service consumer Project, and it needs to access the service in Project B privately. The instances in both projects are not assigned with any external IP.
GCP Region for resources is us-west4
compute.googleapis.com API is enabled in Project A and Project B
Cloud NAT for private instance internet access to download packages
Project A and Project B networks have no internal connectivity. So the instance in Project A cannot access the service running in Project B.
VPC peering is not allowed because of the overlapping range in the default network.
Setup Internal load balancer
An internal load balancer is required for Private Service Connect to expose the service via service attachment. We will create an internal TCP load balancer for this setup in Project B.
Create a new regional HTTP health check to test HTTP connectivity to the VMs on port 80.
Publish the service in Project B, which is the service producer project to allow the consumers in other VPC networks to connect privately and securely access the service.
Reserve a subnet for Private Service Connect. This subnet range should not overlap with the default network.
An endpoint in the service consumer project connects to services in the producer VPC network using a Private Service Connect forwarding rule.
When you create an endpoint, it is automatically registered with Service Directory, using a namespace that you choose or the default namespace, goog-psc-default.
To make the Endpoint available from more than one region, turn on global access. Global access is in Preview.
Reserve an internal IP address to assign to the Endpoint.
Private Service Connect components are now configured in Project A and Project B. Use the endpoint IP in Project A to access the nginx service in Project B.
The test confirms the instances in the overlapping can communicate privately via the Private Service Connect Endpoint.
This example illustrates how you can use Private Service Connect to securely publish and consume services in overlapping networks.
Traffic remains entirely within Google Cloud, providing service-oriented access between consumers and producers with granular control over how services are accessed.
Read more about Private Service Connect on the product page.
\n'yum\ install\ epel-release
Create a managed instance group in Project B.
After the successful creation, the managed instance group launches an instance in the target zone.
SSH into the instance and validate the nginx service status.
Create a connectivity test instance in Project A.
Project A and Project B networks have no internal connectivity. So the instance in Project A cannot access the service running in Project B.
VPC peering is not allowed because of the overlapping range in the default network.
Setup Internal load balancer
An internal load balancer is required for Private Service Connect to expose the service via service attachment. We will create an internal TCP load balancer for this setup in Project B.
Create a new regional HTTP health check to test HTTP connectivity to the VMs on port 80.
Create the backend service for HTTP traffic.
Add the nginx service instance group to the backend service.
Create a forwarding rule for the backend service.
Set up a firewall rule to allow load balancer health checks.
Publish services in service producer project
Publish the service in Project B, which is the service producer project to allow the consumers in other VPC networks to connect privately and securely access the service.
Reserve a subnet for Private Service Connect. This subnet range should not overlap with the default network.
Publish the nginx service to project A with explicit project approval.
Set up a firewall rule to allow Private Service Connect to access the target instances.
Configure Endpoint in service consumer project
An endpoint in the service consumer project connects to services in the producer VPC network using a Private Service Connect forwarding rule.
When you create an endpoint, it is automatically registered with Service Directory, using a namespace that you choose or the default namespace, goog-psc-default.
To make the Endpoint available from more than one region, turn on global access. Global access is in Preview.
Reserve an internal IP address to assign to the Endpoint.
Create a forwarding rule to connect the Endpoint to the Project B service attachment.
Test the connectivity from Consumer Project
Private Service Connect components are now configured in Project A and Project B. Use the endpoint IP in Project A to access the nginx service in Project B.
The test confirms the instances in the overlapping can communicate privately via the Private Service Connect Endpoint.
This example illustrates how you can use Private Service Connect to securely publish and consume services in overlapping networks.
Traffic remains entirely within Google Cloud, providing service-oriented access between consumers and producers with granular control over how services are accessed.
Read more about Private Service Connect on the product page.
\n'yum\ -y\ install\ nginx
Create a managed instance group in Project B.
After the successful creation, the managed instance group launches an instance in the target zone.
SSH into the instance and validate the nginx service status.
Create a connectivity test instance in Project A.
Project A and Project B networks have no internal connectivity. So the instance in Project A cannot access the service running in Project B.
VPC peering is not allowed because of the overlapping range in the default network.
Setup Internal load balancer
An internal load balancer is required for Private Service Connect to expose the service via service attachment. We will create an internal TCP load balancer for this setup in Project B.
Create a new regional HTTP health check to test HTTP connectivity to the VMs on port 80.
Create the backend service for HTTP traffic.
Add the nginx service instance group to the backend service.
Create a forwarding rule for the backend service.
Set up a firewall rule to allow load balancer health checks.
Publish services in service producer project
Publish the service in Project B, which is the service producer project to allow the consumers in other VPC networks to connect privately and securely access the service.
Reserve a subnet for Private Service Connect. This subnet range should not overlap with the default network.
Publish the nginx service to project A with explicit project approval.
Set up a firewall rule to allow Private Service Connect to access the target instances.
Configure Endpoint in service consumer project
An endpoint in the service consumer project connects to services in the producer VPC network using a Private Service Connect forwarding rule.
When you create an endpoint, it is automatically registered with Service Directory, using a namespace that you choose or the default namespace, goog-psc-default.
To make the Endpoint available from more than one region, turn on global access. Global access is in Preview.
Reserve an internal IP address to assign to the Endpoint.
Create a forwarding rule to connect the Endpoint to the Project B service attachment.
Test the connectivity from Consumer Project
Private Service Connect components are now configured in Project A and Project B. Use the endpoint IP in Project A to access the nginx service in Project B.
The test confirms the instances in the overlapping can communicate privately via the Private Service Connect Endpoint.
This example illustrates how you can use Private Service Connect to securely publish and consume services in overlapping networks.
Traffic remains entirely within Google Cloud, providing service-oriented access between consumers and producers with granular control over how services are accessed.
Read more about Private Service Connect on the product page.
After the successful creation, the managed instance group launches an instance in the target zone.
SSH into the instance and validate the nginx service status.
Create a connectivity test instance in Project A.
Project A and Project B networks have no internal connectivity. So the instance in Project A cannot access the service running in Project B.
VPC peering is not allowed because of the overlapping range in the default network.
Setup Internal load balancer
An internal load balancer is required for Private Service Connect to expose the service via service attachment. We will create an internal TCP load balancer for this setup in Project B.
Create a new regional HTTP health check to test HTTP connectivity to the VMs on port 80.
Create the backend service for HTTP traffic.
Add the nginx service instance group to the backend service.
Create a forwarding rule for the backend service.
Set up a firewall rule to allow load balancer health checks.
Publish services in service producer project
Publish the service in Project B, which is the service producer project to allow the consumers in other VPC networks to connect privately and securely access the service.
Reserve a subnet for Private Service Connect. This subnet range should not overlap with the default network.
Publish the nginx service to project A with explicit project approval.
Set up a firewall rule to allow Private Service Connect to access the target instances.
Configure Endpoint in service consumer project
An endpoint in the service consumer project connects to services in the producer VPC network using a Private Service Connect forwarding rule.
When you create an endpoint, it is automatically registered with Service Directory, using a namespace that you choose or the default namespace, goog-psc-default.
To make the Endpoint available from more than one region, turn on global access. Global access is in Preview.
Reserve an internal IP address to assign to the Endpoint.
Create a forwarding rule to connect the Endpoint to the Project B service attachment.
Test the connectivity from Consumer Project
Private Service Connect components are now configured in Project A and Project B. Use the endpoint IP in Project A to access the nginx service in Project B.
The test confirms the instances in the overlapping can communicate privately via the Private Service Connect Endpoint.
This example illustrates how you can use Private Service Connect to securely publish and consume services in overlapping networks.
Traffic remains entirely within Google Cloud, providing service-oriented access between consumers and producers with granular control over how services are accessed.
Read more about Private Service Connect on the product page.