Gateway、HTTPRoute异常定位方法
如果您在使用Envoy Gateway管理Gateway和HTTPRoute时,遇到一些异常状态,例如路由无法生效或流量异常等,请根据本文指导进行逐项排查。
Gateway异常诊断
- 当 Gateway资源的状态为未就绪时,或者关联的负载出现异常时,请参考下表:
异常信息
原因
排查方法
No addresses have been assigned to the Gateway
Gateway关联的Service异常
- 检查Gateway关联的Service状态。
- 使用kubectl describe svc <service-name>查看是否有异常事件(Events)。
Envoy replicas unavailable
Envoy工作负载异常
- 检查Envoy工作负载的状态、Pod 运行情况。
- 查看相关Pod的日志或通过kubectl describe pod查看异常事件。
- 当Gateway资源的状态为无效时,请根据以下方法排查:
- 查询Gateway关联的GatewayClass。
kubectl get gateway <gateway-name> -n <namespace> -o jsonpath='{.spec.gatewayClassName}'
其中<gateway-name>和<namespace>替换为无效gateway的名称和命名空间。
输出示例:
envoy-gateway
- 查询Gatewayclass的controllerName。
kubectl get gatewayclass <gateway-class-name> -o jsonpath='{.spec.controllerName}'其中<gateway-class-name>是上一步中查询出的gatewayClassName。
输出示例:
gateway.envoyproxy.io/gatewayclass-controller
- 结果判定与后续处理:
- 若结果为gateway.envoyproxy.io/gatewayclass-controller:说明绑定正确,请下一步排查EnvoyGateway插件运行状态是否正常。
- 若结果非上述名称:说明该GatewayClass不被EnvoyGateway插件管理,请修改Gateway资源的spec.gatewayClassName重新绑定。
- 查询Gateway关联的GatewayClass。
HTTPRoute异常诊断
当HTTPRoute绑定的Parents状态显示为异常时,通常意味着路由定义与网关存在不匹配或后端服务不可达。请参考下表:
| 异常信息 | 原因 | 排查方法 |
|---|---|---|
| No listeners match this parent ref | parentRef引用的Gateway中,没有任何匹配的Listener。 |
|
| There were no hostname intersections between the HTTPRoute and this parent ref's Listener(s). | HTTPRoute的hostname与Gateway 监听器(Listener)中指定的hostname不匹配。 |
|
| No listeners included by this parent ref allowed this attachment. | HTTPRoute所在的命名空间(Namespace),未被Gateway监听器允许挂载。 |
|
| Failed to process route rule 0 backendRef 0: service default/backeneeeed not found | HTTPRoute路由规则中配置的目标后端Service不存在。 |
|
| 关联的Gateway不存在或状态无效 | 关联的Gateway不存在或状态无效 | 请关联实际存在的Gateway或者确认Gateway状态无效的原因。 |