Connection between Private GKE and Cloud SQL

12/19/2018

I have a Private GKE Cluster with a public master endpoint, which has jobs that needs access Cloud SQL. I have a cloud SQL proxy DaemonSet receiving on 3307, which connects to actual DB on 3306.

My network doesn't have outbound internet, neither any firewalls rules added. I get below error on my cloud SQL proxy. Any help on resolving this or guide on how to establish a connection between private GKE and Cloud SQL ?

couldn't connect to "dbinstance": dial tcp publicip:3307: getsockopt: connection timed out

-- prabhu34
cloud-sql-proxy
google-cloud-platform
google-cloud-sql
google-kubernetes-engine
kubernetes-cluster

1 Answer

12/19/2018

The cloud SQL proxy uses database public IP to connect and as your cluster is private with no internet access from nodes I believe it is impossible to reach it like that. You could try using private IP for your SQL instance:

https://cloud.google.com/sql/docs/mysql/private-ip

or conifguring the NAT gateway for your cluster:

https://cloud.google.com/solutions/using-a-nat-gateway-with-kubernetes-engine

-- jkrol2
Source: StackOverflow