Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Issue Connecting Pod to Cloud SQL Database via Cloud SQL Proxy on GKE Cluster

 

Hello,

I'm encountering an issue while trying to connect my NiFi pod, deployed on a GKE (Google Kubernetes Engine) cluster, to a SQL database on GCP (Google Cloud Platform) using the Cloud SQL Proxy. I've taken the following steps:

  1. Created a user for the database.
  2. Whitelisted the IP address of my NiFi pod.

However, I'm getting the following error in the logs of the Cloud SQL Proxy:

 

arduinoCopy code
2023/09/05 15:57:17 couldn't connect to "project:europe-west1:test-mysql": dial tcp xx.xx.xx.xx:3307: connect: connection timed out 2023/09/05 16:02:52 New connection for "project:europe-west1:test-mysql"
 

Here's a brief summary of my setup:

  • NiFi pod on GKE.
  • Cloud SQL database on GCP.
  • Using the Cloud SQL Proxy to connect.

I've double-checked my configurations, and everything seems to be in order. However, I'm unable to establish a connection, and I'm receiving a "connection timed out" error.

i tried the connection with the public ip of the sql database without passing through the proxy and the connection established without problem. 

Could you please assist me in resolving this issue? If you require more information or specific configurations, please let me know, and I'll provide them while keeping sensitive information hidden.

Thank you for your help.

Sincerely,

0 1 712
1 REPLY 1

Hi @salah-11,

Welcome to Google Cloud Community!

The Cloud SQL Auth Proxy is added to your pod using the sidecar container pattern when you connect utilising the Cloud SQL Auth Proxy. Your application can connect to the Cloud SQL Auth Proxy via localhost, enhancing security and performance, because the Cloud SQL Auth Proxy container is in the same pod as your application.

Visit About the Cloud SQL Auth Proxy for additional details about the Cloud SQL Auth Proxy. The Kubernetes documentation's Pod Overview provides more details on working with pods.

For connecting using the Cloud SQL Auth Proxy you need the following:

  1. The instance connection name of your Cloud SQL instance.
  2. The instance connection name is available in the Cloud SQL Instance details page of the Google Cloud console or from the gcloud sql instances describe INSTANCE_ID command. Check creating a service account for more information.
  3. The Cloud SQL Admin API is enabled.

You may also follow this documentation:

Hope this helps!

 

Top Labels in this Space