Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not connect between Cloud Run and Compute engine using Internal IP

I have a service which runs on Cloud Run, and a MYSQL, MongoDB databases on Compute Engine. Currently, I'm using public IP for connect between them, I want to use internal IP for improving performance, but i cant find solution for this problem, Please help me some ideas, Thanks.

like image 751
HoangThang Avatar asked Jan 20 '20 07:01

HoangThang


3 Answers

Now is supported. You can use VPC network connector (Beta):

This feature is in a pre-release state and might change or have limited support. For more information, see the product launch stages.

This page shows how to use Serverless VPC Access to connect a Cloud Run (fully managed) service directly to your VPC network, allowing access to Compute Engine VM instances, Memorystore instances, and any other resources with an internal IP address.

To use Serverless VPC Access in a Cloud Run (fully managed) service, you first need to create a Serverless VPC Access connector to handle communication to your VPC network. After you create the connector, you set your Cloud Run (fully managed) service configuration to use that connector.

Here how to create: Creating a Serverless VPC Access connector and here an overview about it: Serverless VPC Access example

like image 147
Andre Araujo Avatar answered Oct 16 '22 08:10

Andre Araujo


According to official documentation Connecting to instances using advanced methods

If you have an isolated instance that doesn't have an external IP address (such as an instance that is intentionally isolated from external networks), you can still connect to it by using its internal IP address on a Google Cloud Virtual Private Cloud (VPC) network

However, if you check the services not yet supported for Cloud Run, you will find:

Virtual Private Cloud Cloud Run (fully managed) cannot connect to VPC network.

Services not yet supported

like image 3
marian.vladoi Avatar answered Oct 16 '22 08:10

marian.vladoi


You can now do that by running this command upon deployment:

gcloud run deploy SERVICE --image gcr.io/PROJECT_ID/IMAGE --vpc-connector CONNECTOR_NAME

If you already have a Cloud Run deployment, you can update it by running the command:

cloud run services update SERVICE --vpc-connector CONNECTOR_NAME

More information about that here

like image 2
siamsot Avatar answered Oct 16 '22 09:10

siamsot