Hi, i need some help to enable envoy filter. I just try to add a simple header at envoy_on_response.
I tried this using bookinfo sample application. I don’t see the response header added.
Here is my envoyFilter…
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: test-lua
namespace: default
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_response(response_handle)
– Wait for the entire response body and a response header with the body size.
response_handle:headers():add(“response_body_size”, response_handle:body():length())
end
Am i missed something in this ?
Hello,
You deploy the filter in the default
namespace. Is your gateway also set in this namespace ?
just a quick check if the selector / namespace is correct can be done with:
$ kubectl get pod -n default -l istio=ingressgateway
If you have no pod, you have to update your filter namespace to where your ingress-gateway is deployed.
I try this filter and I got an error with the body length, I guess it is linked to the chuncked transfert mode. the content length cannot be computed before header are sent to the client, the header is not added.
Can you try this filter which set a new hardcoded header ? If this work, you can start playing around.
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: test-lua
namespace: default
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_response(response_handle)
response_handle:headers():add("OK", "KO")
end