不允许带有 rancher 2.2.8 的 traefik v2.0 标签

traefik v2.0 labels with rancher 2.2.8 not allowed

我是 运行 通过 rancher v2.2.8 管理的最新版本的 traefik (v2.0)。

Traefik 运行 很好。 它正在接受连接,我可以通过端口 8080 访问仪表板。

所以我使用 containous/whoami 图像创建了一个新的工作负载,以通过 traefik 公开。

但是,如果我尝试通过 rancher 将标签键 traefik.http.routers.whoami.rule 设置为值 Host(`whoami.example.com`),rancher 会拒绝该值,原因如下:

Validation failed in API: Deployment.apps "whoami" is invalid: spec.template.labels: Invalid value: "Host(`whoami.example.com`)": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

我理解错误消息,但如何在不使用 (` 等字符的情况下使路由正常工作?

traefik 要求标签设置为 (` 等字符,但 rancher 不允许这样的字符。

我使用 https://docs.traefik.io/v2.0/getting-started/quick-start/#traefik-detects-new-services-and-creates-the-route-for-you 作为设置标签的指南。

编辑: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set 还指出,标签键和值不允许使用这些字符。

这不是一个重要的问题,但是 traefik v2.0 如何与 kubernetes 一起工作呢?它不使用标签吗?

原来我看错了文档。带有 kubernetes 的 traefik v2.x 不使用标签将流量分配给特定的工作负载。您的关键字将是 "IngressRoute" 以控制流量。这应该有助于开始工作:docs.traefik.io/v2.2/providers/kubernetes-crd