如何使lua特使过滤器在istio集群上工作?

问题描述 投票:0回答:3

我试图让lua特使过滤器与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
istio envoyproxy
3个回答
0
投票

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

你有2个选择:

  1. 更改workloadLabels
  workloadLabels:
    app: istio-ingressgateway

要么

  1. 删除workloadLabels。 Istio会自动将更改应用于GATEWAY窗格

0
投票

我同意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: |
        ...

0
投票

我有完全一样的问题。我想应用带有GATEWAY listenerType的EnvoyFilter。

我的问题是这个过滤器应用于我的集群上部署的每个istio网关,这不是我想要的。

例如,我有2个网关:一个用于bookinfo样本,另一个用于MyOwnService

现在,如果我使用GATEWAY listenerType部署EnvoyFilter,它将在bookinfo网关和MyOwnService网关上执行。

所以,我打算使用我的EnvoyFilter的spec.workloadLabels属性将它仅应用于MyOwnService网关,但我不知道我必须在这里分配什么标签。因为我处于GATEWAY级别,如果我指定目标部署的标签,则永远不会应用过滤器。

如果我将listenerType更改为SIDECAR_INBOUND,它会按预期工作,因为在边车级别,特使代理“知道”其自己的pod的标签,并且可以相应地(或不)将过滤器应用于workloadLabels。

但是在GATEWAY级别,如何判断过滤器是否应用? spec.workloadLabels真的与GATEWAY listenerType兼容吗?

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.