【问题标题】:Ingressgateway returns a status code different from PodIngressgateway 返回与 Pod 不同的状态码
【发布时间】:2019-01-23 08:55:47
【问题描述】:

我在 GKE 上安装 Istio 并运行应用程序。

虽然使用curl访问没有问题,但是Ingressgateway在浏览器访问时通过一些图片请求返回的状态码与Pod的代理的状态码不同。具体而言,200 和 302 等作为 500 或 504 返回。成为 500 或 504 的资源每次都不同,但它是大约 100 个图像请求中的 1 个或 2 个。如果您再次请求另一个 500 或 504 请求,正确的响应将毫无问题地返回。

你知道是什么原因造成的吗?

环境是这样的。
GKE 1.10.11-gke.1
Istio 1.0.4

helm install install/kubernetes/helm/istio --name istio --namespace istio-system --set tracing.enabled=true --set kiali.enabled=true  --set global.proxy.includeIPRanges="10.0.0.0/8"

以下是从 Stackdriver Logging 获取的日志。

Ingressgateway 日志。

"[2019-01-22T09:16:17.048Z] \"GET /my/app/image.pngHTTP/2\" 504 UT 0 24 60001 - \"xxx.xxx.xxx.xxx\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36\" \"c0abe3be-1153-45c5-bd8e-067ab597feb4\" \"my.app.com\" \"10.128.0.116:80\" outbound|80|ga|myapp.default.svc.cluster.local - 10.128.0.16:443 xxx.xxx.xxx.xxx:62257\n"

Application Pod 的 istio-proxy 日志。

"[2019-01-22T09:16:17.048Z] \"GET /my/spp/images.pngHTTP/1.1\" 200 - 0 3113 0 0 \"xxx.xxx.xxx.xxx\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36\" \"c0abe3be-1153-45c5-bd8e-067ab597feb4\" \"my.app.com\" \"127.0.0.1:80\" inbound|80||myapp.default.svc.cluster.local - 10.128.0.116:80 xxx.xxx.xxx.xxx:0\n"

nginx 日志。

{
  "uri": "/my/app/image.png",
  "host": "my.app.com",
  "requestTime": "0.000",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36",
  "xForwardedProto": "https",
  "user": "",
  "protocol": "HTTP/1.1",
  "bodyByteSize": "3113",
  "method": "GET",
  "remoteAddress": "127.0.0.1",
  "upstreamResponseTime": "",
  "request": "GET /my/app/images.png HTTP/1.1",
  "referrer": "https://my.app.com/",
  "status": "200",
  "xForwardedFor": "xxx.xxx.xxx.xxx"
}

查看此日志,我认为 Ingressgateway 正在丢弃来自 Pod 的响应。

【问题讨论】:

    标签: kubernetes google-kubernetes-engine istio


    【解决方案1】:

    proxy's log 中的UT 表示发生了超时:

    UT:除了 504 响应代码之外的上游请求超时。

    尝试通过在Destination Rule 中指定Connection Pool Settings 来增加连接超时:

    apiVersion: networking.istio.io/v1alpha3
    kind: DestinationRule
    metadata:
      name: myapp
      namespace: default
    spec:
      host: myapp.default.svc.cluster.local
      trafficPolicy:
        connectionPool:
          tcp:
            connectTimeout: 10s
    

    【讨论】:

    • 我试过了,但没有解决。 VirtualService 指定的超时时间过后返回 504。即使您设置的时间长于 VirtualService 中指定的超时时间。
    • VirtualService 的超时时间是多少?
    • 是 60 秒。请求后 60 秒后浏览器将返回 504。
    • 你能同时增加两者吗,例如到 600 年代。下载该文件需要多长时间?
    • 即使在 600 秒内,它在访问 600 秒后也得到了 504。当 curl 或浏览器为 my.app.com/my/app/image.png 时,它将是 200,但当由 my.app.com/topcss 访问时,它将是 504。/top 可以访问大约 150 到 180 个图像,其中 1 或 2 个无法访问 504,其余的在 200 中成功。我使用 http2 访问图像。
    猜你喜欢
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 2017-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-09
    • 1970-01-01
    相关资源
    最近更新 更多