1. 使用端口转发(只能本机访问)

kubectl port-forward $(kubectl get pods --selector "app.kubernetes.io/name=traefik" -n kube-system --output=name) -n kube-system 9000:9000

curl http://127.0.0.1:9000/dashboard/
curl http://172.16.xx.x:9000/dashboard/  不能访问

2. 使用ip访问(调通)

dashboard.yaml

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: dashboard
spec:
  entryPoints:
    - web
  routes:
    - match: PathPrefix(`/dashboard`) || PathPrefix(`/api`)
      kind: Rule
      services:
        - name: api@internal
          kind: TraefikService


kubectl apply -f  /dataF/k8s/tfk/dashboard.yaml

curl http://172.16.0.64/dashboard/
curl http://x.x.x.x/dashboard/

3 使用域名

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: dashboard
spec:
  entryPoints:
    - web
  routes:
    #  && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))
    - match: Host(`dash.xxx.cn`)
      kind: Rule
      services:
        - name: api@internal
          kind: TraefikService



kubectl apply -f dash.yaml
测试
http://dash.xxx.cn/dashboard/