【发布时间】:2021-03-22 17:48:12
【问题描述】:
我正在尝试在我的本地开发环境中运行 Ambassador API 网关,因此我将模拟我最终将在生产环境中得到的结果 - 不同之处在于,在生产环境中我的解决方案将在 Kubernetes 中运行。为此,我将 Ambassador 安装到 Docker Desktop 中,并添加所需的配置以将请求路由到我的微服务。不幸的是,它对我不起作用,我收到以下错误:
upstream connect error or disconnect/reset before headers. reset reason: connection failure
我认为这是由于映射文件中的问题,如下所示:
apiVersion: ambassador/v2
kind: Mapping
name: institutions_mapping
prefix: /ins/
service: localhost:44332
所以我基本上想要做的是将所有到达http://{ambassador_url}/ins 的请求重写为在端口44332 上的IIS Express(通过Visual Studio)中本地运行的服务。
我错过了什么?
【问题讨论】:
-
尝试将
service中的localhost更改为您机器的本地IP,例如192.168.5.10:44332。不要使用环回地址(例如 127.0.0.1)。 -
很遗憾这不起作用。
-
这可能是因为IP地址毕竟不是服务。我的错。它会产生任何日志吗?您是否尝试过创建外部名称或无头服务来将主机的 IP 作为服务创建?
-
如何将主机的 IP 创建为对 Docker 中的大使可见的服务?一个例子将不胜感激。
-
试试这个:``` apiVersion: v1 kind: Service metadata: name: my-localhost spec: type: ClusterIP clusterIP: None --- kind: Endpoints apiVersion: v1 metadata: name: my-本地主机子集:-地址:-ip:10.1.1.5 #你的主机IP在这里```。抱歉格式化。
标签: docker kubernetes microservices api-gateway ambassador