cloud-sql-proxy icon indicating copy to clipboard operation
cloud-sql-proxy copied to clipboard

CSQL_PROXY_ADDRESS requires an IP address but doesn't explicitly state so

Open ar-qun opened this issue 9 months ago • 5 comments

Description

When setting CSQL_PROXY_ADDRESS to cloud-sql-proxy I get the error below.

Error: not a valid IP address: "cloud-sql-proxy"

Potential Solution

Given that the word address is used for both domain names and IPs either it would be great to have disambiguation. I can also make a feature request.

Additional Details

No response

ar-qun avatar May 14 '24 12:05 ar-qun

@ar-qun can you tell me a bit more about your use case? I'd expect CSQL_PROXY_ADDRESS to be set to either 127.0.0.1, a static IP, or possibly 0.0.0.0.

enocom avatar May 14 '24 15:05 enocom

@enocom I am running Cloud SQL Proxy in GKE as a separate K8s Deployment and I want the pods to be accessible only from the current namespace. There is a low chance that someone will expose the service to the outside but using a domain name would for sure keep the traffic internal.

It also might be a bit confusing like it was to me.

ar-qun avatar May 14 '24 16:05 ar-qun

Are you running the Proxy behind a connection pooler? Normally, we recommend running the Proxy as a sidecar (and only listen on localhost) or possibly put it behind a connection pooler (with the proxy also listening only on localhost).

There might still be a use-case here, but the root issue might be how you're using the Proxy.

enocom avatar May 14 '24 16:05 enocom

Not, yet. Currently, Cloud SQL Proxy as single container in a deployment just to try things out. After my trials I will either put Cloud SQL Proxy behind pgbouncer, as is explained in the examples, or switch to the Cloud SQL Language Connectors.

My understanding the issue with running SQL that way is that it is not secure right?

ar-qun avatar May 14 '24 17:05 ar-qun

Yes. Typically we expect traffic to and from the Proxy to be bound to localhost (or a pod), where the workload is contained onto a single VM.

enocom avatar May 14 '24 18:05 enocom

Thanks, enocom.

I will follow the the example with PgBouncer then[1].

[2] https://github.com/GoogleCloudPlatform/cloud-sql-proxy/tree/main/examples/k8s-service

ar-qun avatar May 18 '24 08:05 ar-qun