gpt4 book ai didi

kubernetes - Traefik信息中心-自定义API路径

转载 作者:行者123 更新时间:2023-12-02 12:13:52 24 4
gpt4 key购买 nike

我可以将Traefik仪表板的默认api路径从/api更改为其他内容吗?不幸的是,我发现this link不再起作用。

在我的场景中,Traefik充当Kubernetes入口 Controller ,并且我正在使用基于路径的路由。现在的问题是,我无法将/api用于自己的微服务,因为仪表板已经使用了该路径(these endpoints)。

仪表板的入口配置:

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

最佳答案

您可以如下自定义

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的对应文档 here

关于kubernetes - Traefik信息中心-自定义API路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59575542/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com