微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

k8s,Istio:删除传输编码头

如何解决k8s,Istio:删除传输编码头


在应用程序的响应中,我们看到加倍的 transfer-encoding 标头。
假设,因此我们在 UI 中得到 503,但同时应用程序在 pod 的日志中返回 201。
除了 http code: 201 之外,日志中有 transfer-encoding=chunkedtransfer-encoding=chunked 标头,因此这可能是 503 的原因。
我们曾尝试通过 Istio 虚拟服务或特使过滤器删除 transfer-encoding,但没有成功..

以下是我们尝试过的示例:

VS 定义:

kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
Metadata:
  name: test
  namespace: my-ns
spec:
  hosts:
    - my-service
  http:
    - route:
        - destination:
            host: my-service
          headers:
            response:
              remove:
                - transfer-encoding

---
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
Metadata:
  name: test
  namespace: istio-system
spec:
  gateways:
    - wildcard-api-gateway
  hosts:
    - my-ns_domain
  http:
    - match:
        - uri:
            prefix: /operator/api/my-service
      rewrite:
        uri: /my-service
      route:
        - destination:
            host: >-
              my-service.my-ns.svc.cluster.local
            port:
              number: 8080
          headers:
            response:
              remove:
                - transfer-encoding

EnvoyFilter 定义:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
Metadata:
  name: test
  namespace: istio-system
spec:
  configPatches:
  - applyTo: HTTP_FILTER
    match:
      context: SIDECAR_OUTBOUND
    patch:
      operation: ADD
      value:
        name: envoy.filters.http.lua
        typed_config:
          "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
          inlineCode: |
           function envoy_on_response(response_handle)
             response_handle:headers():remove("transfer-encoding")
           end

在较旧的特使版本中,我看到 envoy.reloadable_features.reject_unsupported_transfer_encodings=false 是一种解决方法。不幸的是,它已被弃用。

请告知 VS/filter 有什么问题,或者是否有替代 reject_unsupported_transfer_encodings 选项的选项?

Istio v1.8.2
特使 v1.16.1

解决方法

目前的决定:要求开发团队消除分块编码的重复

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。