【问题标题】:How to make a lua envoy filter work on the istio cluster?如何让 lua envoy 过滤器在 istio 集群上工作?
【发布时间】:2019-11-12 16:57:49
【问题描述】:

我正在尝试让一个 lua envoy 过滤器与 istio 网关一起使用,但我添加到集群中并且它正在工作,就好像过滤器不存在一样。

我已经使用本指南 https://istio.io/docs/setup/kubernetes/install/kubernetes/ 在 GKE 上配置了我的 istio 集群。

有人遇到过同样的问题吗?

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: edge-lua-filter
spec:
  workloadLabels:
    app: httpbin-gateway
  filters:
  - listenerMatch:
      listenerType: GATEWAY
    filterName: envoy.lua
    filterType: HTTP
    filterConfig:
      inlineCode: |
        -- Called on the request path.
        function envoy_on_request(request_handle)
            request_handle:headers():add("foo", "bar")
        end
        -- Called on the response path.
        function envoy_on_response(response_handle)
            body_size = response_handle:body():length()
            response_handle:headers():add("response-body-size", tostring(body_size))
        end
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: httpbin-gateway
  namespace: foo
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: httpbin
  namespace: foo
spec:
  hosts:
  - "*"
  gateways:
  - httpbin-gateway
  http:
  - route:
    - destination:
        port:
          number: 8000
        host: httpbin.foo.svc.cluster.local

【问题讨论】:

  • 您是否使用“kubectl get EnvoyFilter”命令进行交叉检查?

标签: istio envoyproxy


【解决方案1】:

您正在将过滤器应用于网关。入口网关的“app”名称是“istio-ingressgateway”,而不是“httpbin-gateway”

你有两个选择:

  1. 更改工作负载标签
  workloadLabels:
    app: istio-ingressgateway

  1. 删除工作负载标签。 Istio 会自动将更改应用到 GATEWAY pod

【讨论】:

    【解决方案2】:

    我同意 larsitto 的观点,即您可能对 workloadLabels 有问题 - 尝试将其留空或指定您在部署中指定的一些标签>spec>template>labels []

    例如,此代码适用于我:

    apiVersion: networking.istio.io/v1alpha3
    kind: EnvoyFilter
    metadata:
      name: hello_world
    spec:
      workloadLabels:
      filters:
      - listenerMatch:
          listenerType: SIDECAR_INBOUND
          listenerProtocol: HTTP
        filterName: envoy.lua
        filterType: HTTP
        filterConfig:
          inlineCode: |
            ...
    

    【讨论】:

      【解决方案3】:

      如果使用 filterType HTTP,还需要定义值为 HTTP 的 listenerProtocol 属性。

      另见:

      https://istio.io/docs/reference/config/networking/v1alpha3/envoy-filter/

      注意 3:对于 filterType: HTTP 的过滤器,您必须包含一个带有 listenerProtocol: HTTP 的 listenerMatch 部分,否则过滤器无效。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-07-23
        • 2020-10-24
        • 1970-01-01
        • 2018-02-11
        • 1970-01-01
        • 2020-07-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多