Istio如何使用EnvoyFilter更改特使边车的“ max_request_bytes”?

时间:2020-04-26 11:25:41

标签: kubernetes istio envoyproxy

我想使用istio资源EnvoyFilter更改Sidecar配置以支持自定义max_request_bytes,因为在将太大的文件上传到服务器时会遇到错误413。但是我对特使配置不熟悉。

有人可以给我有效的EnvoyFilter配置吗?谢谢!

2 个答案:

答案 0 :(得分:1)

在Istio 1.2和1.4上可以使用,但是API已更改,filters已弃用:

对于网关(在与网关相同的名称空间中):

---
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: request-size-limit
spec:
  filters:
    - listenerMatch:
        listenerType: GATEWAY
        listenerProtocol: HTTP
      filterName: envoy.buffer
      filterType: HTTP
      filterConfig:
        maxRequestBytes: 26214400 # 25MB

应该最多可以工作1.6(在1.4上进行测试)。未经修改,它将无法在1.7版中运行:

---
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: request-size-limit
  namespace: istio-system
spec:
  configPatches:
    - applyTo: HTTP_FILTER
      match:
        context: GATEWAY
        listener:
          filterChain:
            filter:
              name: "envoy.http_connection_manager"
      patch:
        operation: INSERT_BEFORE
        value:
          name: envoy.buffer
          config:
            maxRequestBytes: 26214400 # 25MB

答案 1 :(得分:0)

对于1.7,此方法有效:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: request-size-limit
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      istio: ingressgateway
  configPatches:
    - applyTo: HTTP_FILTER
      match:
        context: GATEWAY
        listener:
          filterChain:
            filter:
              name: "envoy.http_connection_manager"
      patch:
        operation: INSERT_BEFORE
        value:
          name: envoy.buffer
          typed_config:
            '@type': type.googleapis.com/udpa.type.v1.TypedStruct
            value:
              maxRequestBytes: 1048576  # 1 MB