【问题标题】:Istio VirtualService always 404sIstio VirtualService 总是 404s
【发布时间】:2019-09-16 20:01:45
【问题描述】:

我通过一个简单的 http 网关运行了一个 VirtualService,一切正常:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: satc-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: report
spec:
  hosts:
  - report-create.default.svc.cluster.local
  gateways:
  - satc-gateway
  http:
  - match:
    - uri:
      prefix: /v1/report
    route:
    - destination:
        host: report-create
        port:
          number: 8080

此后,我通过同一个网关为集群中的第二个服务添加了第二个 VirtualService

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: routing
spec:
  hosts:
  - routing-svc.default.svc.cluster.local
  gateways:
  - satc-gateway
  http:
  - match:
    - uri:
        prefix: /v1/routing
    route:
    - destination:
        host: routing-svc.default.svc.cluster.local
        port:
          protcol: http
          number: 8080

虽然第一个 VirtualService 似乎仍在服务,但第二个始终是 404。我添加了一个简单的端点 "/v1/routing/test" 来返回一条 Hello World 消息,以确保问题不会从应用程序逻辑中产生。

两个 VirtualService 似乎都按预期运行,尽管只有对 report 的请求返回 404 以外的任何内容:

report    [satc-gateway]   [report-create.default.svc.cluster.local]   2h
routing   [satc-gateway]   [routing-svc.default.svc.cluster.local]     18m

我已尝试将第一个部署全部删除,以确保它现在可以吸收所有进入集群的流量并仍然得到 404。我还尝试从 pod 内部执行路由并获得成功响应,这两个服务都使用容器端口 8080,我也对其进行了三次检查。

我似乎遇到了一些困难,不确定要正确调试的下一个最佳步骤是什么。

【问题讨论】:

    标签: kubernetes kubernetes-ingress istio


    【解决方案1】:

    我分析了你的两个 yaml,发现第二个的问题很少:

    • prefix: 行中有 2 个额外的空格
    • “protocol:”行中有错字(遗漏了o)
    • destination: 部分存在一些差异

    请进行调整,如果有帮助,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-25
      • 2021-08-10
      • 1970-01-01
      • 1970-01-01
      • 2019-05-13
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      相关资源
      最近更新 更多