我想从不同的GCP项目连接到Cloud SQL。
Cloud SQL位于ProjectSQL中,该项目中有一个名为sql_vpc的VPC网络。
另外还有一个名为ProjectDataflow的项目,该项目有一个名为dataflow_vpc的VPC。我想使用在ProjectDataflow项目中启动的VM连接到ProjectSQL中的Cloud SQL。
我尝试过一些方法,有成功也有失败:
私有访问:
VPC对等连接:
Enable Private IP access in Cloud with the vpc sql_vpc
Creating VPC peering between dataflow_vpc and sql_vpc
This solution does not work because you can not access the Peered Network.
https://cloud.google.com/sql/docs/mysql/private-ip
Status: FAILED
共享网络As per doc I can create the CloudSQL in shared VPC network, that says I
have to create the CloudSQL in host project, and to access the Cloud
SQL from VM instance, it has be in the same network as of authorized
private ip network of Cloud SQL
Status: NOT TRIED but looks to be Negative
公共访问:
Create a Cloud NAT in ProjectDataflow with dataflow_vpc with manual IP
Use the Cloud NAT public ip to whitelist in CloudSQL instance
Now I can access the CloudSQL from project ProjectDataflow using CloudSQL Public IP
STATUS: Success
请分享您从另一个项目访问Cloud SQL的经验。是否有连接另一个GCP项目中的Cloud SQL的最佳实践?