Eri*_*son 7 kubernetes traefik configmap k3s k3d
*交叉发布到k3d github 讨论、 Rancher 论坛中的主题以及traefik 的社区讨论板
2020 年的教程涉及编辑 traefik 配置图。它去哪儿了?
traefik安装说明提到了几种公开仪表板的方法:
这有效,但不持久:使用 1-time 命令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 和/或我的无知。
对于 2 服务器、2 代理集群...kubectl -n kube-system describe deploy traefik
不显示任何配置图:
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
Run Code Online (Sandbox Code Playgroud)
并且,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
Run Code Online (Sandbox Code Playgroud)
描述 pod 也没有显示任何内容。kubectl -n kube-system describe pod traefik-....
结果也没有配置映射。
但是,我确实看到了 traefik pod 的参数以及正在使用的端口:
--entryPoints.traefik.address=:9000/tcp
--entryPoints.web.address=:8000/tcp
--entryPoints.websecure.address=:8443/tcp
Run Code Online (Sandbox Code Playgroud)
但是,这些端口并未暴露。因此,我尝试使用 进行端口转发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
Run Code Online (Sandbox Code Playgroud)
k3d version v4.4.7
k3s version v1.21.2-k3s1 (default)
Run Code Online (Sandbox Code Playgroud)
小智 19
我找到了一个解决方案,希望有人很快找到更好的解决方案
/etc/rancher/k3s/k3s.yaml
到您的本地~/.kube/config
(以便在最后一步中转发到您的电脑)
kubectl get pod -n kube-system
搜索traefik-something-somethingElse
我的是traefik-97b44b794-bsvjn
kubectl port-forward traefik-97b44b794-bsvjn -n kube-system 9000:9000
http://localhost:9000/dashboard/
您最喜欢的浏览器,不要忘记第二个斜杠请注意,您必须首先/var/lib/rancher/k3s/server/manifests/traefik.yaml
通过添加来启用仪表板
dashboard:
enabled: true
Run Code Online (Sandbox Code Playgroud)
Rin*_*gil 11
雅库布的回答非常好。但不幸的是,如果 k3s 重新启动,配置会被重置。根据k3s 文档,如果您创建一个名为 的自定义文件/var/lib/rancher/k3s/server/manifests/traefik-config.yaml
,k3s 的 traefik 将使用此新配置自动更新并使用其值。这是我所拥有的:
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: traefik
namespace: kube-system
spec:
valuesContent: |-
dashboard:
enabled: true
ports:
traefik:
expose: true # this is not recommended in production deployments, but I want to be able to see my dashboard locally
logs:
access:
enabled: true
Run Code Online (Sandbox Code Playgroud)
通过这个设置,你可以跳过port-forward
ing直接进入http://localhost:9000/dashboard/
!
归档时间: |
|
查看次数: |
18460 次 |
最近记录: |