首页 > 解决方案 > 我应该为服务使用哪个匹配器,托管在本地 Service Fabric 集群的 localhost {port} 上

问题描述

我有一个关于 Service Fabric 和 Traefik 的问题。

我已经成功地将 Traefik 应用程序部署到本地集群(实际上也部署在我自己的 Azure Infra 中)。这是我试图让 Traefik (RP) 坐在前面的另一个应用程序中的服务 (MyService) 旁边。

我可以看到 Traefik 仪表板,并且可以看到一个后端(似乎表明它已经成功地为我的应用程序和服务正确调用了 SF 管理 API)。

我还可以看到附带的前端,带有一些路由规则(匹配器)。但是,对于我的生活,我无法通过 RP 获得对我的服务的简单请求。

我可以直接点击我的服务。Service Fabric (SF) 表示它也处于良好状态。

我的本地 SF 集群不安全,因此通过 .toml 设置等可以简化一些事情。

我的服务托管在 localhost:9025 上(端点暴露在服务清单和端口设置(API 中的 Kestrel)中)也是一样的。

Traefik 设置在端口 5000(而不是 80 - 见下文)上。

要明确地进行简单的版本检查,我会使用http://localhost:9025/myservice/myaction/v1/version

执行http://localhost:5000/myservice/myaction/v1/version会得到 404 或 503(取决于我对匹配器/修饰符所做的事情)。

我也将 Traefik 端点从端口 80 修改为 5000,只是为了将其切换并避免任何端口冲突。(我现在没有 IIS 站点。) Netstat 确认也没有使用其他端口。

服务清单中的匹配器如下所示:

             <Extensions>
                <Extension Name="Traefik">
                    <Labels xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
                        <Label Key="traefik.frontend.rule">PathPrefix:/myservice</Label>
                        <Label Key="traefik.enable">true</Label>
                    </Labels>
                </Extension>
```            </Extensions>

One last thing, I guess, that would have really helped would be the ability to see the "resolved" requests.  That is a request that comes into the RP, and then is matched or modified so that I can see what the RP actually reconciles a request out too. Perhaps this already exists, but tweaking of various logging didn't yield this info.

标签: traefikazure-service-fabric

解决方案


好的,所以与 Traefik 相关的 Service Manifest 并没有错,而是 Traefik 不理解的 Manifest 中 Endpoint 的暴露。

这不起作用:

<Endpoint Name="MyService" Protocol="http" Type="Input" Port="9025" />

但是,这将:

<Endpoint Name="MyService" UriScheme="http" Port="9025" />

(我省略的其他属性仍然可以添加,但这似乎是 Traefik 将其枚举为可行后端所需的最低要求)

Traefik 日志中有明确的接线指示(以前不存在)

Wiring frontend frontend-fabric:/MyApp/MyService to entryPoint http

并且,在 UI 中,对于后端,服务器 URI 再次显示,这不是以前的。

如果这在某处记录在案,请原谅我,但除了我认为没有看到服务器 URI 是基于 Service Fabric 和 Traefik 设置网站上的屏幕截图的问题之外,我找不到任何其他内容。

另一个症状是,如果未正确连接后端,它将显示为红色,正确配置后将显示为绿色。

正如我所说,一切都可能非常明显,但我在这个我需要做的简单修改上浪费了很多时间。


推荐阅读