You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在GCP Service Mesh(原Traffic Director)中配置请求转发至Cloud Run

解决Service Mesh中接入Cloud Run Serverless NEG的后端配置错误

问题场景

按GCP Service Mesh文档搭建了客户端VM,已实现托管实例组的请求负载均衡,但配置路由到Cloud Run应用时遇到问题:创建Serverless网络端点组(NEG)后,无法将其添加到网格的HTTP路由中,执行添加后端命令时触发错误:

`gcloud.compute.backend-services.add-backend) Could not fetch resource:

  • Invalid value for field 'resource.backends[0]': '{ "group": "https://compute.googleapis.com/compute/v1/projects/blah/regions/us-central1/...'. Invalid load balancing scheme for global backend service with Serverless network endpoint group.`

错误原因

你创建的是全局级的INTERNAL_SELF_MANAGED后端服务,但Serverless NEG属于区域级资源,全局后端服务与Serverless NEG的负载均衡方案不兼容,导致报错。

正确配置步骤

1. 创建区域级Serverless NEG

Cloud Run对应的Serverless NEG是区域资源,无需指定可用区,直接用区域参数创建:

gcloud compute network-endpoint-groups create hello-green-neg --cloud-run-service hello-green --network-endpoint-type=serverless --region=us-central1

2. 创建区域级INTERNAL_SELF_MANAGED后端服务

将后端服务改为区域级,保持负载均衡方案为INTERNAL_SELF_MANAGED:

gcloud compute backend-services create hello-blue-backend --region=us-central1 --load-balancing-scheme=INTERNAL_SELF_MANAGED

3. 添加Serverless NEG到后端服务

指定对应区域完成后端关联:

gcloud compute backend-services add-backend hello-blue-backend --network-endpoint-group hello-blue-neg --network-endpoint-group-region=us-central1 --region=us-central1

完成以上步骤后,即可将该后端服务关联到Service Mesh的HTTP路由,实现请求转发到Cloud Run应用。

内容的提问来源于stack exchange,提问作者JedA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 01:33:09