GKE pod connectivity to Cloud SQL

3/25/2020

Please enlighten me.

Current Setup: Docker container running inside the VM instance - The docker container can connect to our Cloud SQL with all the credentials included in the property file during the building of docker image

Future Setup: I deployed this container as a pod on my GKE but it couldn't connect to my Cloud SQL. I am just confused, Do I still need to do an extra step like the guide below before I can establish a connection to my Cloud SQL DBs?

https://cloud.google.com/sql/docs/mysql/connect-kubernetes-engine

Since the property file where all the DB credentials where package together during the building process of an image, I should be able to connect to Cloud SQL DBs from GKE pod right?

\====

kubectl logs -f appds-d599f75d4-wn9x6

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up
-- erlchamp
google-cloud-platform
google-cloud-sql
google-kubernetes-engine
kubernetes

1 Answer

3/27/2020

For private GKE clusters GKE worker nodes and pods running on those nodes access other GCP APIs such as Cloud SQL via Private API Access

architecture

-- Arghya Sadhu
Source: StackOverflow