将来自 marktplace kubernetes 引擎的 consul 应用程序与微服务 google cloud run 连接起来

问题描述

我实现了 Google Marketplace 中提供的 Consul 应用程序,并使用 Cloud Run 创建了一个应在 Consul 中注册的微服务。但是,微服务(spring boot 应用程序)无法识别网络上的 Consul 服务的名称。我已连接到共享 VPC,以便双方可以看到对方,但出现以下错误

Caused by: java.net.UnkNownHostException: consul: Name or service not kNown

而我的部署代码如下

gcloud run deploy bpms-gateway --image $CONTAINER_REGISTRY/$GCP_PROJECT_ID/$IMAGE_REPOSITORY/bpms-gateway:0.0.2 --platform managed --region $RUN_REGION --port 8080 --vpc-connector=vcp-p2f-connector --update-env-vars SPRING_CLOUD_CONSUL_HOST=consul --allow-unauthenticated

尝试过:

  1. 通过创建一个环境变量 SPRING_CLOUD_CONSUL_HOST 将服务名称传递给它,完全复制我在本地环境中所做的事情(使用 docker-compose);

  2. 将值 consul-shared-consul-server (Consul HTTP API) 传入变量但未解决

来自 GCP 中组件 consul 应用程序的信息:

Image with info from components consul application in GCP

有什么想法可以解决这个问题吗?谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)