繁体   English   中英

使用 Traefik 的 Kube.netes-Dashboard 的 IngressRoute

[英]IngressRoute for Kubernetes-Dashboard using Traefik

我正在将我的项目移动到 Kube.netes,使用 Traefik 进行路由,使用 MetalLB 作为我的负载均衡器。

我已经部署了几个应用程序,我想使用官方的Kube.netes-Dashboard 所以我使用推荐的配置部署了 Kube.netes-Dashboard 并创建了 IngressRoute:

# dashboard.yaml
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`k8s.example.com`, `www.k8s.example.com`)
      kind: Rule
      middlewares:
        # - name: https-redirectscheme
        # - name: nginx-basic-auth
      services:
        - kind: Service
          name: kubernetes-dashboard
          # namespace: kubernetes-dashboard
          port: 443
  tls:
    secretName: k8s.example.com-tls

它显示在 Traefik 仪表板中,但是当我尝试访问 k8s.example.com 时,我得到了Internal Server Error

谢谢

我有同样的问题 - 这就是为什么我结束这个问题。 当我发现如何使用IngressRoute ,我会更新这个答案。

此答案描述了如何改用NodePort

kubectl patch svc kubernetes-dashboard -p '{"spec": {"type": "NodePort"}}'
# Confirm
kubectl get svc -n kubernetes-dashboard kubernetes-dashboard -o yaml

# patch the dashboard
tee ~/nodeport_dashboard_patch.yaml<<EOF
spec:
  ports:
  - nodePort: 32000
    port: 443
    protocol: TCP
    targetPort: 8443
EOF

kubectl patch svc kubernetes-dashboard --patch "$(cat ~/nodeport_dashboard_patch.yaml)"

现在可以通过 Traefik 与 MetalLB 合作提供的外部 IP 端口访问仪表板:32000。
如果您有一个网站路由到您的集群,您可以使用:

https://yourwebsite.com:32000

如您共享的链接中所述,使用以下方法获取令牌:

export SA_NAME= # admin user from the ServiceAccount
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep ${SA_NAME} | awk '{print $1}')

(我可以更改此答案以获得完整的脚本来执行此操作;如果您愿意的话)

在这里找到答案: https://stackoverflow.com/a/69999245/3883694

您可以禁用 SSL 证书验证。

https://doc.traefik.io/traefik/routing/overview/#transport-configuration

---
apiVersion: traefik.containo.us/v1alpha1
kind: ServersTransport
metadata:
  name: traefik-dashboard-transport
  namespace: traefik
spec:
  serverName: traefik-dashboard
  insecureSkipVerify: true
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: dashboard
spec:
  entryPoints:
    - web
  routes:
    - match: (PathPrefix(`/dashboard`) || Host(`traefik.example.com`))
      kind: Rule
      services:
      - name: api@internal
        kind: TraefikService
      serversTransport: traefik-dashboard-transport

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM