Communication between two private networks in Google Cloud networking - networking

I have two networks Pvt-net1 and Pvt-net2 as custom subnet networks in Google cloud networking.
Each of network is having one subnet.
Pvt-net1 is having subnet pvt-net1subnet1 192.168.1.0/16 in region us-central1.
Pvt-net2 is having subnet pvt-net2subnet1 192.168.2.0/16 in region us-central1.
I don't want to have both subnets under same network. I am trying to map Openstack networking to Google Cloud networking.
How can form communication between Pvt-net1 and Pvt-net2 with private IP's?
Can I use routes and firewalls here? What could be better way to setup routing between to different networks in same Google project?
Edit:
I am working on Openstack project which maps Openstack network resources to Google Cloud networking Resources.
I am mapping Openstack network, subnet to Google cloud network, subnet. Now as we create route between networks in Openstack, I want to map same action to GCE.

1) You have not elaborated on your use case, but maybe you can create one network with 2 [sub-networks]
(https://cloud.google.com/compute/docs/subnetworks).
2) If you need 2 separate networks, you can use network peering or create two Cloud VPN (one per network),which are connected to each other.

VPC networks can be connected to other VPC networks in different projects or organizations by using VPC Network Peering.

Related

Connect to a GCP Redis instance that is connected to a different VPC network

On GCP, peered VPC connections are not transitive and Memorystore exists in it's own VPC network. This means that it's not possible to connect to a Redis instance from multiple VPC networks. Only a single authorized network is able to get access.
This diagram illustrates how VPC-2 cannot connect to VPC-1's Redis instance:
[Redis]-[VPC-1]-[VPC-2]
The only proposed solution I've found so far to connect from multiple VPC networks is to host a Redis proxy (nutcracker)
but this feels like a lot of work and potential maintenance in the future.
Is there a managed service offered by GCP that can do the trick?
I've recently connected a private GKE cluster to Cloud Build following this documentation which makes use of routers and tunnels, is it possible to use a Cloud Router and VPN tunnels to proxy the connection?
Another solution so you can manage the peered VPCs within the same project:
As you know, peered VPCs are not transitive, in this case meaning your VPC-2 does not know about the connection between VPC-1 and Redis VPC.
You can use VPC-1 as a transit network, by either importing and exporting routes between VPC-1 and VPC-2 or for a more managed solution you could use Cloud VPN on your VPC-1. If you have multiple VPCs that you need to connect to Redis, I would suggest considering using the Cloud VPN.
Here is an example of how this architecture could work
From this example, look at network-b as your VPC-1 and Network-a as your Redis VPC and Network-c as your VPC-2.
If you only have a few VPCs that need to connect to the Redis VPC, you could also consider exporting and importing custom routes from VPC-1 to all peered VPC that need access to Redis.
For Redis please note that only IPs from RFC1918 are allowed to connect so your IPs that need to connect to Redis would need to be in these ranges
10.0.0.0 – 10.255.255.255 (10/8 prefix)
172.16.0.0 – 172.31.255.255 (172.16/12 prefix)
192.168.0.0 – 192.168.255.255 (192.168/16 prefix)

How to connect multiple cloud with overlapping VPC?

We are creating a Console to administer, view logs and metrics, create resources on Kubernetes in a multicloud environment.
The Console ( a web app ) is deployed on GKE in GCP, but we can't figure out how we can connect and reach K8S Api-Servers in multiple VPC with overlapping IPs, without exposing them on public IP.
I draw a little diagram to expose the problem.
Are there some products or best practice to perform this securely?
Product vendors for example Mongo Atlas or Confluent Cloud seems to have solved this issue, they can create infrastructure in multiple cloud and administer them.
It's not possible to connect two overlapping networks with VPN even if they're in different clouds (GCP & AWS).
I'd suggest to use NAT translation on both sides and connect networks using VPN.
Here's some documentation that may help you. Unfortunatelly it's quite a bit of reading and setting up. Not the easiest solution but it has the benefit of being reliable and it's a quite old and tested approach.
General docs
Configure NAT to Enable Communication Between Overlapping Networks
Using NAT in Overlapping Networks
GCP side
Cloud NAT overview
Using Cloud NAT
AWS side
NAT instances
Comparison of NAT instances and NAT gateways
You second option is to split the original networks in smaller chunks so they wold not overlap but that's not always possible (due to network being small enough already and many IP's are used up...).
It depends on couple factors in the environments.
To access an overlapping network you need some form of gateway.
it can be some kind of proxy socks/http/other or a router/gw(with nat..).
If you can access the 192.168.23.0/24 or any other subnet that can connect to the aws 192.168.2.0/24 subnet from gcp then you can use either one of the solutions.
I assume that aws and gcp can provide the tunnel between the gw/proxy network.
If you don't need security layer for the tunnel you can use a vxlan tunnel and secure the tcp/other app protocol.
Using Google Cloud VPN with AWS Virtual Private Gateway you can accomplish such a thing. A detailed description by Google is given in this documentation.
It describes two VPN topologies:
A site-to-site Route-based IPsec VPN tunnel configuration.
A site-to-site IPsec VPN tunnel configuration using Google Cloud Router and dynamic routing with the BGP protocol.
Additionally, when CIDR-ranges overlap. You would need to create a new VPC/CIDR ranges that are non-overlapping. Otherwise, you could never connect to instances that have IP-addresses in both AWS and GCP.

Does GKE use an overlay network?

GKE uses the kubenet network plugin for setting up container interfaces and configures routes in the VPC so that containers can reach eachother on different hosts.
Wikipedia defines an overlay as a computer network that is built on top of another network.
Should GKE's network model be considered an overlay network? It is built on top of another network in the sense that it relies on the connectivity between the nodes in the cluster to function properly, but the Pod IPs are natively routable within the VPC as the routes inform the network which node to go to to find a particular Pod.
VPC-native and non VPC native GKE clusters uses GCP virtual networking. It is not strictly an overlay network by definition. An overlay network would be one that's isolated to just the GKE cluster.
VPC-native clusters work like this:
Each node VM is given a primary internal address and two alias IP ranges. One alias IP range is for pods and the other is for services.
The GCP subnet used by the cluster must have at least two secondary IP ranges (one for the pod alias IP range on the node VMs and the other for the services alias IP range on the node VMs).
Non-VPC-native clusters:
GCP creates custom static routes whose destinations match pod IP space and services IP space. The next hops of these routes are node VMs by name, so there is instance based routing that happens as a "next step" within each VM.
I could see where some might consider this to be an overlay network. I don’t believe this is the best definition because the pod and service IPs are addressable from other VMs, outside of GKE cluster, in the network.
For a deeper dive on GCP’s network infrastructure, GCP’s network virtualization whitepaper can be found here.

Google Cloud VPN over NAT

I'm trying to configure VPN between Google Cloud and a few on premise subnetworks hidden behind NAT. The problem is that I have only 1 external IP address and as I've said I'd like to create multiple VPN connections to few (~10) subnetworks which are hidden behind NAT. Is it possible?
Unfortunately it is not possible.
GCP VPNs just support one-to-one NAT and this means a single Internal IP matching a single External IP.

Communication between tenant network and existing network in openstack

I am trying to make the tenant network communicate with an existing network which did not build in OpenStack. we all know we can allocate a floating IP to VM with external network, but now we have no need access Internet, so we would not allocate IP to VM, just want to make tenant VM can communicate with another network, how do I map the existing network to OpenStack and create router between them?
Any help would be appreciated.Thanks!
There are certain steps to do this.
You need to add a routing entry for the tenant network in compute nodes.
You need to use Masquerading on compute node.
I think with this configuration you will be able to establish communication between tenant network and existing physical network.

Resources