raphael_mav
raphael_mav

Reputation: 580

Mirror requests from cloudrun service to other cloudrun service

I'm currently working on a project where we are using Google Cloud. Within the Cloud we are using CloudRun to provide our services. One of these services is rather complex and has many different configuration options. To validate how these configurations affect the quality of the results and also to evaluate the quality of changes to the service, I would like to proceed as follows:

This allows me to create a detailed evaluation of the differences between the two services without having to provide the user with potentially worse responses.

For the implementation I have setup a NGINX which mirrors the requests. This is also deployed as a CloudRun service. This now accepts all requests and takes care of the authentication. The original service and the mirrored version have been configured in such a way that they can only be accessed internally and should therefore be accessed via a VPC network.

I have tried all possible combinations for the configuration of these parts but I always get 403 or 502 errors.

I have tried setting the NGINX service to the HTTP and HTTPS routes from the service, and I have tried all the VPC Connector settings. When I set the ingress from the service to ALL it works perfectly if I configure the service with HTTPS and port 443 in NGINX. As soon as I set the ingress to Internal I get errors with HTTPS -> 403 and with HTTP -> 502.

Does anyone have experience in this regard and can give me tips on how to solve this problem? Would be very grateful for any help.

Upvotes: 4

Views: 327

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75715

If your Cloud Run service are internally accessible (ingress control set to internal only), you need to perform your request from your VPC.

Therefore, as you perfectly did, you plugged a serverless VPC connector on your NGINX service.

The set up is correct. Now, why it works when you route ALL the egress traffic and not only the private traffic to your VPC connector?

In fact, Cloud Run is a public resource, with a public URL, and even if you set the ingress to internal. This param say "the traffic must come to the VPC" and not say "I'm plugged to the VPC with a private IP".

So, to go to your VPC and access a public ressource (Your cloud run services), you need to route ALL the traffic to your VPC, even the public one.

Upvotes: 2

Related Questions