VPC Network Setup for Private IP access from GKE to Cloud SQL

170 views
Skip to first unread message

Aniket Bhadane

unread,
Jul 23, 2019, 4:25:31 AM7/23/19
to Google Cloud SQL discuss
Our Spring 4 Application runs on Google Kubernetes Engine (GKE). I was going through articles for accessing Cloud SQL DB using Private IP. But I'm struggling in setting up the VPC requirements for this. From my understanding, we would need one VPC network where the Cloud SQL instance would exist. And we would need another VPC network in which our kubernetes deployment in running. And then we would have to peer the two networks. How does google facilitate creation of VPC network for Kubernetes deployment, how do you peer the two VPC networks in google cloud, what is the scope of network assignment (project, cluster, etc.), what are the conditions of IP ranges, etc. Is there any guide for setting up VPC networks for connecting GKE application to Cloud SQL?

Pedro Castro Silva

unread,
Jul 23, 2019, 7:18:03 AM7/23/19
to google-cloud...@googlegroups.com
Hi Aniket,

I did something similar last week and it's quite easy.

1. Create the VPC network for the Kubernetes deployment, including IP ranges and stuff
2. Create the Cloud SQL instance on VPC network defined in step 1 and activate Private IP access. Let Google create the interconnection between the database network (which you can't control) and the VPC defined in step 1.
3. Voilá! You can now access your database through the private IP.

Manual VPC peering setups are trickier but I you'll probably not going to need one.

Cheers,
Pedro

Aniket Bhadane <abha...@avaya.com> escreveu no dia terça, 23/07/2019 à(s) 09:25:
Our Spring 4 Application runs on Google Kubernetes Engine (GKE). I was going through articles for accessing Cloud SQL DB using Private IP. But I'm struggling in setting up the VPC requirements for this. From my understanding, we would need one VPC network where the Cloud SQL instance would exist. And we would need another VPC network in which our kubernetes deployment in running. And then we would have to peer the two networks. How does google facilitate creation of VPC network for Kubernetes deployment, how do you peer the two VPC networks in google cloud, what is the scope of network assignment (project, cluster, etc.), what are the conditions of IP ranges, etc. Is there any guide for setting up VPC networks for connecting GKE application to Cloud SQL?

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/68d19e67-8e06-475c-9763-8206f25ef441%40googlegroups.com.

Julie (cloud platform support)

unread,
Jul 23, 2019, 9:43:45 AM7/23/19
to Google Cloud SQL discuss
This document goes though connecting GKE with Cloud SQL and one of the prerequisites before connection is creating a VPC-native cluster. The IPs are naively routable within the GCP network (including via VPC Network Peering) so you can set one up, create a Cloud SQL instance and configure it with private IP which includes using that same VPC Network peering that is connected with the GKE (configuring private services access is also necessary). 

Aniket Bhadane

unread,
Jul 24, 2019, 1:12:00 AM7/24/19
to Google Cloud SQL discuss
Hi Pedro,

Please can you tell how you did the first point, i.e. creation of VPC network for the Kubernetes deployment? I'm not find a way to assign a network for a kubernetes deployment



On Tuesday, July 23, 2019 at 4:48:03 PM UTC+5:30, Pedro Castro Silva wrote:
Hi Aniket,

I did something similar last week and it's quite easy.

1. Create the VPC network for the Kubernetes deployment, including IP ranges and stuff
2. Create the Cloud SQL instance on VPC network defined in step 1 and activate Private IP access. Let Google create the interconnection between the database network (which you can't control) and the VPC defined in step 1.
3. Voilá! You can now access your database through the private IP.

Manual VPC peering setups are trickier but I you'll probably not going to need one.

Cheers,
Pedro

Aniket Bhadane <abha...@avaya.com> escreveu no dia terça, 23/07/2019 à(s) 09:25:
Our Spring 4 Application runs on Google Kubernetes Engine (GKE). I was going through articles for accessing Cloud SQL DB using Private IP. But I'm struggling in setting up the VPC requirements for this. From my understanding, we would need one VPC network where the Cloud SQL instance would exist. And we would need another VPC network in which our kubernetes deployment in running. And then we would have to peer the two networks. How does google facilitate creation of VPC network for Kubernetes deployment, how do you peer the two VPC networks in google cloud, what is the scope of network assignment (project, cluster, etc.), what are the conditions of IP ranges, etc. Is there any guide for setting up VPC networks for connecting GKE application to Cloud SQL?

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsub...@googlegroups.com.

Pedro Castro Silva

unread,
Jul 24, 2019, 6:23:47 AM7/24/19
to google-cloud...@googlegroups.com
When you create a cluster, you'll notice a link below the CPU and memory information that says something like "Availability, network, security, (...)". Click it and you'll have access to more options. One of them is the network where your cluster will operate. Choose your custom VPC and you're set.

Reply all
Reply to author
Forward
0 new messages