Comparison of ways to connect to Google Cloud SQL database from GKE

106 views
Skip to first unread message

Aniket Bhadane

unread,
Jul 30, 2019, 10:44:25 AM7/30/19
to Google Cloud SQL discuss
I have been exploring ways to securely connect to Google Cloud SQL database. We use Google Kubernetes Engine for deployment of our Java Spring application.

So, https://cloud.google.com/sql/docs/mysql/connect-kubernetes-engine mentions of two methods to connect to cloud sql from kubernetes. We cannot use private IP method since we do not have VPC native clusters. So we choose Cloud SQL Proxy docker image as the connection medium.

Then, considering https://cloud.google.com/sql/docs/postgres/external-connection-methods, there are following options mentioned:

42xb6.png



We cannot go by Public IP approach since our kubernetes pod IP address will be ever changing. We have already shortlisted Cloud SQL Proxy docker image. So we are left with JDBC Socket Library.

So, comparing Cloud SQL proxy and JDBC Socket Library:

 - Cloud SQL proxy would be a sidecar container in our kubernetes pod along with our application container. The application container will connect to 'localhost:5432' (proxy) with the cloud sql credentials. The proxy will be given the service account for accessing the cloud sql database. The proxy provides secure connection to cloud sql.
 - JDBC Socket Library also provides secure connection to cloud sql. A Maven dependency needs to added in the application, and the application just has to provide correct database connection string.

From the above comparison, JDBC Socket Library seems to be the better way since we won't be needing a sidecar container - cloud sql proxy.

Is there any advantage that the Cloud SQL Proxy would provide as compared to JDBC Socket Library in the case where the application is deployed in Google Kubernetes Engine?

Elliott (Google Cloud Platform Support)

unread,
Jul 30, 2019, 5:32:19 PM7/30/19
to Google Cloud SQL discuss

Hello Aniket,


Please note that Google Groups are reserved for general Google Cloud Platform-end product discussions and not for technical issues, which is why I suggest moving the troubleshooting to Stackoverflow to obtain assistance from our programming community for your question.



Reply all
Reply to author
Forward
0 new messages