I am setting up a connection to a CloudSQL Postgres instance from Datastream via private connection. I have referred to the similar questions in the community I could find, and taken the following steps but still haven’t been successful:
- allocated an IP range (/29) in my VPC for Datastream
- ensured the VPC has a firewall rule allowing ingress via TCP protocol over port 5432 with source filter set to the allocated IP range
- ensured export custom routes in Private Services Access for the VPC is enabled for both cloudsql-postgres-googleapis-com and servicenetworking-googleapis-com
- verified that the route which contains the internal IP address of the database appears in the Exported routes tab of the VPC Network Peering page.
- set up a reverse proxy to cloud sql in a new VM within the VPC to be peered based on these instructions (https://cloud.google.com/datastream/docs/private-connectivity#reverse-csql-proxy) and added a startup script as outlined here: https://cloud.google.com/compute/docs/instances/startup-scripts/linux#passing-local
- verified that the reverse proxy VM can psql into the CloudSQL instance via its the internal IP address. (Note: when i tried to ping the internal IP address from the reverse proxy VM, it did not return any packets)
- created a Datastream Private connectivity configuration for the VPC
- added custom advertised route for the IP range i allocated for Datastream (per https://cloud.google.com/network-connectivity/docs/router/how-to/advertising-subnets#console)
- tried to set up a connection profile using the private connectivity config, with the host set to the IP of the reverse proxy and port 5432
When I attempted to test the connection profile before adding the startup script to the reverse proxy, and adding custom advertised route, I got a timeout error. Now that I’ve taken those steps, I get the following error:
We can't connect to the source database using the specified hostname and port. Make sure that the hostname and port are correct and that the database can accept inbound connections.
My questions:
-
What do I need to change to get datastream connected to my cloudsql instance via private connectivity?
-
will a reverse proxy intercept all traffic to the db (i’m especially concerned about traffic from the app it is the backend db for), or will it be used only for datastream traffic? If all traffic, what impact might I expect on performance of requests to the db? Would using cloudsql auth proxy versus reverse proxy be more performant?