0

我有运行 3 个容器的 k8s pod:我的应用程序、opa、特使

我的所有设置都遵循本指南:https ://www.openpolicyagent.org/docs/latest/envoy-authorization/

一切都很顺利,直到我拥有 15kb JSON 正文。

检查我在 request.http.body 中看到的 OPA 容器日志——那里只有大约一半的 JSON。

{
  "decision_id": "",
  "error": {},
  "input": {
    "attributes": {
      "destination": {
        "address": {
          "Address": {
            "SocketAddress": {
              "PortSpecifier": {
                "PortValue": 8000
              },
              "address": "10.244.8.102"
            }
          }
        }
      },
      "request": {
        "http": {
          "body": "only half of JSON body come here",
          "headers": {
            ":authority": "api-service.com",
            ":method": "PUT",
            ":path": "/api",
            "accept": "application/json",
            "content-length": "14822",
            "content-type": "application/json",
            "x-envoy-decorator-operation": "....",
            "x-envoy-internal": "true",
            "x-forwarded-for": "10.244.6.0",
            "x-forwarded-proto": "https",
            "x-istio-attributes": "..."  
          },
          "host": "....com",
          "id": "12114967460600931537",
          "method": "PUT",
          "path": "/api",
          "size": 14822
        }
      },
      "source": {
        "address": {
          "Address": {
            "SocketAddress": {
              "PortSpecifier": {
                "PortValue": 34670
              },
              "address": "10.244.3.164"
            }
          }
        }
      }
    },
    "parsed_path": [
      "api"
    ],
    "parsed_query": {}
  },
  "level": "info",
  "msg": "Decision Log",
  "query": "data.app.allow",
  "type": "openpolicyagent.org/decision_logs"
}

我尝试增加with_request_body。

http_filters:
   - name: envoy.ext_authz
        config:
          with_request_body:
            max_request_bytes: 819200
            allow_partial_message: true
            failure_mode_allow: false

还有什么我错过的吗?

非常感谢你的帮助

4

2 回答 2

0

我最终通过增加 max_request_bytes 使其工作。

name: envoy.ext_authz
        config:
          with_request_body:
            max_request_bytes: 819200

我之前在 configmap 中进行了配置,但忘记重新启动 pod。只需使用新的 max_request_bytes 重新部署所有内容 - 现在可以了

参考:https ://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/buffer/v3/buffer.proto.html?highlight=max_request_bytes 谢谢大家

于 2020-06-18T05:43:31.400 回答
0

Envoy 日志中是否有任何错误?

您要发送的数据是什么?它是否需要成为 OPA输入文档的一部分,或者您可以利用 OPA 的捆绑功能。

于 2020-06-16T16:07:38.790 回答