GoogleCloudPlatform / cloud-sql-proxy

A utility for connecting securely to your Cloud SQL instances
Apache License 2.0
1.28k stars 349 forks source link

More cloudsql connection #2319

Closed wagnerww closed 2 hours ago

wagnerww commented 3 hours ago

Question

I use cloudsql as a sidecar and I have 2 connections in the following model:

How do I run this in version 2?

Code

No response

Additional Details

No response

jackwotherspoon commented 2 hours ago

Hi @wagnerww thanks for the great question! 😄

What you are looking for is instance level configuration, this can be done with query strings.

https://github.com/GoogleCloudPlatform/cloud-sql-proxy/blob/bf75246386a5c4fe5bc46274f8565b295b280a1c/cmd/root.go#L143-L160

The v2 command for you would be:

./cloud-sql-proxy <INSTANCE_NAME>  <INSTANCE_NAME2>?address=127.0.0.2&port=5432

[!NOTE]

Your could optionally add the ?address=127.0.0.1&port=5432 query string to the first instance connection name, however I omitted it for simplicity as the first configured instance will default to 127.0.0.1:5432.

To see a full list of supported features you can always run ./cloud-sql-proxy --help

Migration guide with more details can be found here: https://github.com/GoogleCloudPlatform/cloud-sql-proxy/blob/main/migration-guide.md

Let me know if this works for you, if it does not feel free to re-open this and I will take another look.