1

我可以将仪表板的 Traefik 的默认 api 路径更改为/api其他路径吗?不幸的是,我发现这个链接不再起作用了。

Traefik 在我的场景中充当 Kubernetes 入口控制器,我正在使用基于路径的路由。现在的问题是我不能/api用于我自己的微服务,因为仪表板已经使用了这个路径(这些端点)。

仪表板的入口配置:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: traefik-web-ui
  annotations:
    kubernetes.io/ingress.class: traefik 
    traefik.ingress.kubernetes.io/priority: "2"
spec:
  rules:
  - http:
      paths:
      - path: /dashboard
        backend:
          serviceName: traefik-web-ui
          servicePort: http
      - path: /api <-- needed to make dashboard's api available
        backend:
          serviceName: traefik-web-ui
          servicePort: http 

微服务之一的入口配置:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: backend
  annotations:
    kubernetes.io/ingress.class: traefik 
    traefik.ingress.kubernetes.io/priority: "999"
spec:
  rules:
  - http:
      paths:
      - path: /apis/ <-- i'd rather use /api here
        backend:
          serviceName: {{ include "my-backend.fullname" . }}
          servicePort: http 
4

1 回答 1

1

您可以按如下方式自定义它

defaultEntryPoints = ["http"]

[entryPoints]
  [entryPoints.http]
  address = ":80"

  [entryPoints.foo]
  address = ":8080"

  [entryPoints.bar]
  address = ":8081"

# Activate API and Dashboard
[api]
entryPoint = "bar"
dashboard = true

[file]
  [backends]
    [backends.backend1]
      [backends.backend1.servers.server1]
      url = "http://127.0.0.1:8081"

  [frontends]
    [frontends.frontend1]
    entryPoints = ["foo"]
    backend = "backend1"
      [frontends.frontend1.routes.test_1]
      rule = "PathPrefixStrip:/yourprefix;PathPrefix:/yourprefix"

Traefik 的相应文档在这里

于 2020-01-03T10:41:25.660 回答