Cannot connect to Cloud SQL from VMware Engine

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
  1. Setup Cloud SQL instance with private IP connected to Virtual Private Cloud.
  2. Ensure that PSA is configured and workload VMs running can access Virtual Private Cloud.
  3. Setup and configure a VM instance on Virtual Private Cloud.
  4. 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.
  5. Enable firewall rules on Virtual Private Cloud to allow connection to port specified in the above command.
  6. 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.