我正在使用部署面向外部的服务,该服务暴露在节点端口后面,然后是istio入口。部署使用手动边车注入。一旦部署,nodeport和入口都在运行,我就可以向istio入口发出请求。
由于某些未知原因,该请求不会路由到我的部署,而是显示文本“上游没有健康”。为什么会这样,原因是什么?
我可以在http响应中看到状态代码为503(服务不可用),服务器为“特使”。部署正在运行,因为我可以将端口映射到该端口,并且一切正常。
以防万一,像我一样,你会好奇......即使在我的场景中,错误的情况很明显......
错误原因: 我有同一服务的两个版本(v1 和 v2),以及使用权重配置了流量路由目的地的 Istio VirtualService。然后,95% 进入 v1,5% 进入 v2。当然,由于我还没有部署 v1,所以 95% 的请求都会出现错误“503 - nohealthyupstream”。
好吧,即便如此,我知道问题所在以及如何修复它(只需部署 v1),我想知道......但是,我如何才能获得有关此错误的更多信息?我怎样才能更深入地分析这个错误以找出发生了什么?
这是使用 Istio 配置命令行实用程序 istioctl 进行调查的一种方法:
# 1) Check the proxies status -->
$ istioctl proxy-status
# Result -->
NAME CDS LDS EDS RDS PILOT VERSION
...
teachstore-course-v1-74f965bd84-8lmnf.development SYNCED SYNCED SYNCED SYNCED istiod-86798869b8-bqw7c 1.5.0
...
...
# 2) Get the name outbound from JSON result using the proxy (service with the problem) -->
$ istioctl proxy-config cluster teachstore-course-v1-74f965bd84-8lmnf.development --fqdn teachstore-student.development.svc.cluster.local -o json
# 2) If you have jq install locally (only what we need, already extracted) -->
$ istioctl proxy-config cluster teachstore-course-v1-74f965bd84-8lmnf.development --fqdn teachstore-course.development.svc.cluster.local -o json | jq -r .[].name
# Result -->
outbound|80||teachstore-course.development.svc.cluster.local
inbound|80|9180-tcp|teachstore-course.development.svc.cluster.local
outbound|80|v1|teachstore-course.development.svc.cluster.local
outbound|80|v2|teachstore-course.development.svc.cluster.local
# 3) Check the endpoints of "outbound|80|v2|teachstore-course..." using v1 proxy -->
$ istioctl proxy-config endpoints teachstore-course-v1-74f965bd84-8lmnf.development --cluster "outbound|80|v2|teachstore-course.development.svc.cluster.local"
# Result (the v2, 5% of the traffic route is ok, there are healthy targets) -->
ENDPOINT STATUS OUTLIER CHECK CLUSTER
172.17.0.28:9180 HEALTHY OK outbound|80|v2|teachstore-course.development.svc.cluster.local
172.17.0.29:9180 HEALTHY OK outbound|80|v2|teachstore-course.development.svc.cluster.local
# 4) However, for the v1 version "outbound|80|v1|teachstore-course..." -->
$ istioctl proxy-config endpoints teachstore-course-v1-74f965bd84-8lmnf.development --cluster "outbound|80|v1|teachstore-course.development.svc.cluster.local"
ENDPOINT STATUS OUTLIER CHECK CLUSTER
# Nothing! Emtpy, no Pods, that's explain the "no healthy upstream" 95% of time.
Run Code Online (Sandbox Code Playgroud)
尽管这是由于 Istio 设置不当导致的路由问题导致的普遍错误,但我将为遇到相同问题的任何人提供通用解决方案/建议。
就我而言,问题是由于路由规则配置不正确造成的,Kubernetes 本机服务正在运行,但是 Istio 路由规则配置不正确,因此 Istio 无法从入口路由到服务。
| 归档时间: |
|
| 查看次数: |
6748 次 |
| 最近记录: |