Kubernetes的入口路线-使用Traefik的 Jmeter 板

kuuvgm7e  于 2023-01-08  发布在  Kubernetes
关注(0)|答案(2)|浏览(132)

我将把我的项目转移到Kubernetes,使用Traefik进行路由,使用MetalLB作为负载平衡器。
我已经部署了几个应用程序,我想使用官方的Kubernetes-Dashboard。因此,我使用推荐的配置部署了Kubernetes-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 Jmeter 板中,但当我尝试访问www.example.com时k8s.example.com,我得到Internal Server Error
谢谢

kkbh8khc

kkbh8khc1#

我也有同样的问题--这就是为什么我在这个问题上结束。当我找到如何使用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)"

现在, Jmeter 板可以达到外部IP Traefik给你-与MetalLB合作-端口: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}')

(我可以将此答案更改为完成此操作的完整脚本;如果你愿意)

m528fe3b

m528fe3b2#

在这里找到了答案: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

相关问题