You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

K8s 1.29.x集群创建IngressRoute成功但kubectl查不到

问题描述

我在Kubernetes 1.29.x集群中尝试创建IngressRoute,对应的YAML配置如下:

apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: ai-web-route
  namespace: reddwarf-pro
spec:
  entryPoints:
    - web
  routes:
    - kind: Rule
      match: >-
        Host(`ai.example.top`) && (PathPrefix(`/infra/user/login`) ||
        PathPrefix(`/infra/auth/access-token/refresh`) ||
        PathPrefix(`/infra/user/reg`))
      priority: 8
      services:
        - name: infra-server-service
          port: 8081
    - kind: Rule
      match: Host(`ai.example.top`) && PathPrefix(`/infra`)
      middlewares:
        - name: jwt-token-auth
      priority: 2
      services:
        - name: infra-server-service
          port: 8081
    - kind: Rule
      match: Host(`ai.example.top`) && PathPrefix(`/ai`)
      middlewares:
        - name: jwt-token-auth
      priority: 2
      services:
        - name: chat-hub-service
          port: 8081
    - kind: Rule
      match: Host(`ai.example.top`)
      priority: 1
      services:
        - name: ai-web
          port: 80

执行以下命令查询IngressRoute资源:

[root@iZm5e2jhfbrshckqh6qdbuZ ~]# kubectl get ingressroute --all-namespaces -o wide
NAMESPACE      NAME                      AGE
reddwarf-pro   official-website-route    77m
reddwarf-pro   react-admin-new-route     77m
reddwarf-pro   react-admin-route         77m
reddwarf-pro   snap-web-route            77m
reddwarf-pro   tex-websocket-route       77m
reddwarf-pro   tool-web-route            77m
sre            apollo-dev-config-route   77m
sre            apollo-route              77m

结果中未找到新建的ai-web-route资源,我是通过Lens创建该资源的,且Lens显示创建成功,请问我遗漏了什么?

排查方案
  • 精准查询资源状态:直接指定命名空间查询目标资源,确认是否真的创建成功:
    kubectl get ingressroute ai-web-route -n reddwarf-pro -o yaml
    
    如果返回资源不存在,说明Lens的UI反馈有误;如果存在,查看status字段和metadata.annotations,排查是否有异常状态标记。
  • 校验配置合法性:将YAML保存为文件后,执行服务器端 dry-run 校验,排查语法或依赖问题:
    kubectl apply -f ai-web-route.yaml --dry-run=server
    
    重点检查是否存在以下问题:
    • 引用的jwt-token-auth中间件在reddwarf-pro命名空间中不存在
    • 后端服务infra-server-service、chat-hub-service、ai-web未在对应命名空间创建或端口配置错误
  • 检查Traefik CRD兼容性:IngressRoute是Traefik自定义资源,确认集群中CRD是否正确安装且支持traefik.io/v1alpha1版本:
    kubectl get crd ingressroutes.traefik.io -o yaml
    
    如果CRD不存在,说明Traefik未正确部署;如果存在,检查spec.versions字段是否包含v1alpha1。
  • 查看集群事件日志:查询目标命名空间下的事件,获取资源创建失败的具体原因:
    kubectl get events -n reddwarf-pro --sort-by='.metadata.creationTimestamp'
    
  • 核实Lens操作日志:在Lens中找到该资源的创建记录,查看API请求的实际响应,确认是否存在创建失败但UI未同步的情况。

内容的提问来源于stack exchange,提问作者Dolphin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 12:34:57