glesage glesage - 1 year ago 95
MySQL Question

Connecting to multiple CloudSQL instances using Cloud sql proxy?

I'm attempting to use the cloud sql proxy to connect to 2 different cloud sql instances...

In the docs I found a line about

Use -instances parameter. For multiple instances, use a comma-separated list.
but not sure how to make that look. I'm using Google Container engine, and with a single CloudSQL instance it works great:

- name: cloudsql-proxy
command: ["/cloud_sql_proxy", "--dir=/cloudsql",
- name: cloudsql-oauth-credentials
mountPath: /secrets/cloudsql
readOnly: true
- name: ssl-certs
mountPath: /etc/ssl/certs

But for multiple I've tried the
section as such:


but they all give various errors;
, and

Any help is much appreciated!

Answer Source

You cannot have two databases hosted on the same TCP port. Instead, specify ports for each database in the comma-separated list:


I used 3306 and 3307 here, but you can use any ports you want! Make sure that the rest of your Container Engine config allows for communication between nodes on these ports (maybe that's true by default, I don't use GKE).

Most mysql drivers connect to port 3306 by default but have a way to specify another port. You'll have to arrange for your code to connect to the different port you choose for the second database.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download