istio:将 istiogateway 上的 envoyfilter 升级为新语法
istio: upgrade envoyfilter on istiogateway to new syntax
我正在尝试将一些 Lua 代码仅应用于 istio-ingressgateway pod。所以基本上,我想 运行 一些 Lua 代码用于每个进入 ingressgateway 的请求。
我已经能够使用 filters
使它与旧的已弃用语法一起使用,如下所示。
这适用于 Istio 1.4.6:
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: my-filter
namespace: default
labels:
some-labels
spec:
workloadSelector:
labels:
istio: ingressgateway
authn-ns1: enabled
filters:
- filterName: envoy.lua
filterType: HTTP
listenerMatch:
listenerType: GATEWAY
listenerProtocol: HTTP
filterConfig:
inlineCode: |
function envoy_on_request(request_handle)
request_handle:logDebug("Hello World")
end
但是,我无法使它与新语法一起使用,而且我对如何将它们拼凑起来有点困惑。我试图合并文档中的示例,
https://istio.io/docs/reference/config/networking/envoy-filter/
但没有任何运气让它发挥作用。
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: my-filter
namespace: default
spec:
workloadSelector:
labels:
istio: ingress-gateway
configPatches:
- applyTo: NETWORK_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
name: "envoy.http_connection_manager"
patch:
operation: INSERT_BEFORE
value: # lua filter specification
name: envoy.lua
typed_config:
"@type": "type.googleapis.com/envoy.config.filter.http.lua.v2.Lua"
inlineCode: |
function envoy_on_request(request_handle)
request_handle:logDebug("Hello World")
end
我没有找到太多新语法的示例,none 将过滤器应用于入口网关。我确实部署了网关,但我没有使用 sidecar 注入。
你知道我如何制作一个 envoyfilter 以便我可以使用新语法将 Lua 代码应用于每个入站请求吗?是否有任何很好的示例说明如何使用新语法执行此操作?非常感谢任何建议。
这是我在 istio 1 上尝试过的。5.x,我使用了测试用例 tests/testdata/networking/envoyfilter-without-service/configs.yaml
并将 workload
更改为 istio: ingressgateway
以匹配 istio ingressgateway .
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: test-lua
namespace: istio-system
spec:
workloadSelector:
labels:
istio: ingressgateway
configPatches:
- applyTo: HTTP_FILTER
match:
listener:
filterChain:
filter:
name: "envoy.http_connection_manager"
subFilter:
name: "envoy.router"
patch:
operation: INSERT_BEFORE
value: # lua filter specification
name: envoy.lua
typed_config:
"@type": "type.googleapis.com/envoy.config.filter.http.lua.v2.Lua"
inlineCode: |
function envoy_on_request(request_handle)
request_handle:logWarn("Hello World")
end
我正在尝试将一些 Lua 代码仅应用于 istio-ingressgateway pod。所以基本上,我想 运行 一些 Lua 代码用于每个进入 ingressgateway 的请求。
我已经能够使用 filters
使它与旧的已弃用语法一起使用,如下所示。
这适用于 Istio 1.4.6:
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: my-filter
namespace: default
labels:
some-labels
spec:
workloadSelector:
labels:
istio: ingressgateway
authn-ns1: enabled
filters:
- filterName: envoy.lua
filterType: HTTP
listenerMatch:
listenerType: GATEWAY
listenerProtocol: HTTP
filterConfig:
inlineCode: |
function envoy_on_request(request_handle)
request_handle:logDebug("Hello World")
end
但是,我无法使它与新语法一起使用,而且我对如何将它们拼凑起来有点困惑。我试图合并文档中的示例, https://istio.io/docs/reference/config/networking/envoy-filter/ 但没有任何运气让它发挥作用。
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: my-filter
namespace: default
spec:
workloadSelector:
labels:
istio: ingress-gateway
configPatches:
- applyTo: NETWORK_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
name: "envoy.http_connection_manager"
patch:
operation: INSERT_BEFORE
value: # lua filter specification
name: envoy.lua
typed_config:
"@type": "type.googleapis.com/envoy.config.filter.http.lua.v2.Lua"
inlineCode: |
function envoy_on_request(request_handle)
request_handle:logDebug("Hello World")
end
我没有找到太多新语法的示例,none 将过滤器应用于入口网关。我确实部署了网关,但我没有使用 sidecar 注入。
你知道我如何制作一个 envoyfilter 以便我可以使用新语法将 Lua 代码应用于每个入站请求吗?是否有任何很好的示例说明如何使用新语法执行此操作?非常感谢任何建议。
这是我在 istio 1 上尝试过的。5.x,我使用了测试用例 tests/testdata/networking/envoyfilter-without-service/configs.yaml
并将 workload
更改为 istio: ingressgateway
以匹配 istio ingressgateway .
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: test-lua
namespace: istio-system
spec:
workloadSelector:
labels:
istio: ingressgateway
configPatches:
- applyTo: HTTP_FILTER
match:
listener:
filterChain:
filter:
name: "envoy.http_connection_manager"
subFilter:
name: "envoy.router"
patch:
operation: INSERT_BEFORE
value: # lua filter specification
name: envoy.lua
typed_config:
"@type": "type.googleapis.com/envoy.config.filter.http.lua.v2.Lua"
inlineCode: |
function envoy_on_request(request_handle)
request_handle:logWarn("Hello World")
end