*此内容已在k3d github discussions、Rancher论坛上的一篇帖子以及traefik社区讨论版块中都有发布。
2020年的教程提到需要编辑Traefik ConfigMap,但现在它去哪了呢?
Traefik安装说明提到了几种公开Traefik仪表盘的方法:
这种方法可以使用,但不是持久性的:使用一次性命令:
kubectl -n kube-system port-forward $(kubectl -n kube-system get pods --selector "app.kubernetes.io/name=traefik" --output=name) 9000:9000
我无法使此方法起作用:创建一个"IngressRoute" YAML文件并将其应用到集群中。这可能是由于Klipper LB和/或我的无知造成的。
traefik部署未使用configmap
对于一个有2个服务器和2个代理的集群,kubectl -n kube-system describe deploy traefik
没有显示任何configmap:
Volumes:
data:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
tmp:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
Priority Class Name: system-cluster-critical
找不到”traefik“配置映射
kubectl get -n kube-system cm
命令显示:
NAME DATA AGE
chart-content-traefik 0 28m
chart-content-traefik-crd 0 28m
chart-values-traefik 1 28m
chart-values-traefik-crd 0 28m
cluster-dns 2 28m
coredns 2 28m
extension-apiserver-authentication 6 28m
k3s 0 28m
k3s-etcd-snapshots 0 28m
kube-root-ca.crt 1 27m
local-path-config 4 28m
traefik pods未使用configmap
查看pods的描述也没有发现任何内容。使用kubectl -n kube-system describe pod traefik-....
命令也没找到相关的configmap。
Traefik端口被占用但无响应
但是,我发现了Traefik pod 中正在使用的端口参数:
--entryPoints.traefik.address=:9000/tcp
--entryPoints.web.address=:8000/tcp
--entryPoints.websecure.address=:8443/tcp
然而,这些端口未公开。因此,我尝试使用kubectl port-forward命令将它们暴露出来:
kubectl port-forward pods/traefik-97b44b794-r9srz 9000:9000 8000:8000 8443:8443 -n kube-system --address 0.0.0.0
,但是当我使用curl -v localhost:9000
(或8000或8443),以及curl -v localhost:9000/dashboard
时,会出现“404 Not Found”的错误。在获得traefik终端后,我发现了本地打开的端口,但似乎没有任何响应。
/ $ netstat -lntu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 :::8443 :::* LISTEN
tcp 0 0 :::8000 :::* LISTEN
tcp 0 0 :::9000 :::* LISTEN
/ $ wget localhost:9000
Connecting to localhost:9000 ([::1]:9000)
wget: server returned error: HTTP/1.1 404 Not Found
/ $ wget localhost:8000
Connecting to localhost:8000 ([::1]:8000)
wget: server returned error: HTTP/1.1 404 Not Found
/ $ wget localhost:8443
Connecting to localhost:8443 ([::1]:8443)
wget: server returned error: HTTP/1.1 404 Not Found
版本
k3d version v4.4.7
k3s version v1.21.2-k3s1 (default)
kubectl describe
命令。 - P....http://localhost:9000/dashboard/#/http/routers
,看看从dashboard.yml
应用的新入口路由是否反映出来。如果是这样,那么您只需要访问http://<domain>/dashboard/
。 - Jessie Baltazar