Problem
Unable to connect to Cloud SQL from Google Cloud VMware Engine due to no response.
Environment
- Google Cloud VMware Engine
Solution
Use Cloud SQL Auth proxy
- Setup Cloud SQL instance with private IP connected to Virtual Private Cloud.
- Ensure that PSA is configured and workload VMs running can access Virtual Private Cloud.
- Setup and configure a VM instance on Virtual Private Cloud.
- Start Cloud SQL Proxy
- For example: /opt/google/cloud_sql_proxy - instances=PROJECT:REGION:CSQL INSTANCE NAME=tcp:0.0.0.0:3306
- This command will start the proxy to instance on project and region specified on port 3306 and accept connection from any interface. You can replace PORT 3306 with any port that you want to use for SQL connection from client.
- For example: /opt/google/cloud_sql_proxy - instances=PROJECT:REGION:CSQL INSTANCE NAME=tcp:0.0.0.0:3306
- Enable firewall rules on Virtual Private Cloud to allow connection to port specified in the above command.
- Connect to Cloud SQL instance from Google Cloud VMware Engine client and use the Compute Engine instance IP created in step 3 as SQL server and use the proxy port as server port.
Cause
Cloud SQL uses its own umbrella project and connects to your Virtual Private Cloud over Virtual Private Cloud peering, there is no direct way to access it using private IP.