# 03-01 Traefik Dashboard(HelmChartConfig + IngressRoute) # 部署:kubectl apply -f traefik-dashboard.yaml(或复制到 K3s server/manifests/) --- apiVersion: helm.cattle.io/v1 # HelmChartConfig 所在的 API 版本 kind: HelmChartConfig # HelmChartConfig:给 K3s/Traefik chart 注入 values metadata: # 该资源标识 name: traefik # chart 对应的对象名 namespace: kube-system # HelmChartConfig 所在命名空间 spec: # Helm 注入配置 valuesContent: |- # 以“字符串形式的 YAML”注入到 chart values(由 chart 解析) ports: # entrypoint/端口暴露相关配置 web: # HTTP entrypoint expose: true # 启用 web 暴露 websecure: # HTTPS entrypoint expose: true # 启用 websecure 暴露 traefik: #(chart 内部)traefik dashboard/管理端口暴露(按 chart 约定) expose: true # 启用 traefik 管理端口暴露 additionalArguments: # 额外传给 Traefik 的 CLI 参数 - "--api.dashboard=true" # 开启 dashboard 功能 - "--api.insecure=true" # 允许 dashboard 在入口可用(不建议在公网直接放行) --- apiVersion: traefik.io/v1alpha1 # IngressRoute 的 API 版本 kind: IngressRoute # Traefik 的路由 CRD metadata: # IngressRoute 标识 name: traefik-dashboard # 资源名 namespace: kube-system # IngressRoute 所在命名空间 spec: # 路由规则 entryPoints: # 进入的 entrypoint - web # 使用 web(HTTP)入口 routes: # 路由列表 - match: PathPrefix(`/dashboard`) || PathPrefix(`/api`) # 匹配 /dashboard 或 /api 前缀 kind: Rule # 匹配规则类型:Rule services: # 匹配到后转发给的服务列表 - name: api@internal # Traefik 内置 API 服务 kind: TraefikService # 该服务的 CRD 类型