0

I am trying to retrieve data from Cloud SQL via Cloud Composer DAG to GCS.

  1. I tried giving the public/private ip of the cloud sql instance in the airflow mysql_conn connection.

MySQLdb._exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'xx.xxx.xx.x' (110)")

  1. Tried installing cloud proxy and changed airflow connection host to 127.0.0.1

MySQLdb._exceptions.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (111)") 3. Enabled the Private IP & selected the network the same as cloud composer network. still same issue.

ping has no response to Private IP in cloud shell. ping has response to Public IP in cloud shell.

Can anyone help on the same? like what should be done for a composer dag to access the tables in cloud sql?

Cloud Composer network: enter image description here

Cloud SQL: enter image description here

mehere
  • 1,487
  • 5
  • 28
  • 50

1 Answers1

0

In order to connect Cloud Composer to Cloud SQL via private IP, please enable Export custom routes in the VPC peering between your VPC network and Cloud SQL's VPC network.

Once the exporting of custom routes is enabled, the VPC network of the Cloud SQL instance knows where to route the pod traffic and connection can be successfully established

You can achieve this by following these steps:

Cloud Console Main Menu > VPC Network > VPC network peering > servicenetworking-googleapis-com > edit > enable the export custom route.

You can refer to this doc for more information.

Sandeep Mohanty
  • 1,419
  • 5
  • 13
  • Hi Sandeep both composer and the sql is in same vpc. Is the VPC network perring still required for the same? – mehere Dec 23 '21 at 14:54
  • Hi @EvaMariam Could you check if the service account that is used to establish connection between Cloud Composer and Cloud SQL has the required permissions granted? You can refer to this doc for Cloud SQL [roles](https://cloud.google.com/iam/docs/understanding-roles#cloud-sql-roles). – Sandeep Mohanty Dec 29 '21 at 12:16