Envoy lua 过滤器 - http 调用集群无效。必须进行配置

我正在尝试为部署在运行 istio 的 GKE 群集上的所有微服务创建 envoy 过滤器。

在过滤器中,我想读取 2 个标题值并向 Web 上的外部服务发送请求,以获取用户拥有权限的所有组列表。

当我发送请求时,我收到“http 调用集群无效。必须进行配置”错误。

根据我的理解,我们需要将主机注册为集群,以便 Envoy 理解请求应该发送到哪里,我已在 my filter.yaml 文件的“clusters”部分中添加了一个值。

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: authorization-filter
  namespace: default
spec:
  filters:
  - listenerMatch:
      listenerType: SIDECAR_INBOUND
      listenerProtocol: HTTP
    filterName: envoy.lua
    filterType: HTTP
    filterConfig:
      inlineCode: |
        function envoy_on_request(request_handle)
          request_handle:logWarn("Inside filter")
          local token = request_handle:headers():get("Authorization")
          local partition = request_handle:headers():get("partition-id")
          if token == nil or partition == nil then
            request_handle:logErr("Token or Partition is empty")
            request_handle:respond({[":status"] = "400",["Content-Type"] = "application/json"}, "{\"ErrorMessage\":\"Bad Request: Authorization or Partition-Id missing in headers\"}")
          end
          request_handle:logWarn("Sending request")
          local headers, body = request_handle:httpCall(
            "lua_cluster",
            {
              [":method"] = "GET",
              [":authority"] = "example.com",
              [":path"] = "/api/authorization/groups",
              ["Authorization"] = token,
              ["partition-id"] = partition
            },
            nil,
            5000)
          request_handle:headers():add("authorization-response-headers", headers)
        end

  clusters:
  - name: lua_cluster
    connect_timeout: 0.5s
    type: strict_dns
    lb_policy: round_robin
    hosts:
    - socket_address:
        address: "example.com"
        port_value: 8888

我在这里漏掉了什么?

点赞