Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Communication cloud build to cloud run

Hi,
I am trying to call one of my cloud run services via cloud build.

My cloud run service network is configured with
- Ingress control: internal
- A VPC connector to our default VPC network on this project
For cloud build,
- I create a private pool on the default VPC network of this project as well and using a custom IP range which I created following https://cloud.google.com/build/docs/private-pools/set-up-private-pool-to-use-in-vpc-network

However, with this setup, the builds fail because the requests to https://MYCLOUDRUN.run.app/get failed with 404.

Thanks for your help!

2 2 467
2 REPLIES 2

Hi @outflier,

Welcome to Google Cloud Community!

There are several ways on how to resolve error 404:

For Cloud Run:

  • Make sure that the URL being requested is correct by checking the service detail page in the Cloud console or by running the following through Cloud shell:
    gcloud run services describe [service_name] | grep [URL]
  • Check for errors in Cloud Logging.
  • Make sure that your app does not start listening on its configured port before it is ready to receive requests.
  • Run your app locally and check if it doesn't return 404.
  • Check if ingress settings are set to "Internal" or "Internal and Cloud Load Balancing". 404 should not be present in Cloud Logging when using this filter:
    resource.type="cloud_run_revision"
    log_name
    ="projects/[project_id]/logs/run.googleapis.com%2Frequests"
    httpRequest
    .status=404

For Cloud Build:

  • Check your source code location and try again.
  • Your repo may not contain a build config file
  • Trigger ID is incorrect
  • Connect your new repository to Cloud Build if your recently added a new repo and Cloud Build doesn't have permission to access the new repo.
  • Permission is not granted to the service account.

You may check the following documentations for your reference:

Hope this helps.

The requests from Cloud Build shared or private work pools are not considered internal, So it is not possible to access the cloud run endpoint from Cloud Build if you set the ingress control to internal only. You need to expose the cloud run behind an internal load balancer or a proxy to access the cloud run service from the cloud build. Refer to https://cloud.google.com/run/docs/securing/private-networking#from-gcp

Screenshot 2024-03-07 at 15.48.00.png