Problem creatting lua filter

Hello,

I have been using this yaml to try to create lua filter on istio 1.4.5.

kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: lua-filter
  namespace: foo
spec:
  workloadSelector:
    labels:
      app:  httpbin
  configPatches:
    # The first patch adds the lua filter to the listener/http connection manager
  - applyTo: HTTP_FILTER
    match:
      context: SIDECAR_INBOUND
      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:headers():replace("lua-filter", "lua-filter")
           end
EOF

Currently I am getting this error:
Error from server: error when creating “STDIN”: admission webhook “pilot.validation.istio.io” denied the request: configuration is invalid: envoy filter: unknown message type “envoy.config.filter.http.lua.v2.Lua”

Can you anyone help me understand what is happening?

Maybe the type_config form is not supported < 1.5

The example in the 1.4 docs for EnvoyFilters use the ‘config’ form

...
patch:
  operation: INSERT_BEFORE
  value: # lua filter specification
   name: envoy.lua
   config:
     inlineCode: |
       function envoy_on_request(request_handle)
         -- Make an HTTP call to an upstream host with the following headers, body, and timeout.
         local headers, body = request_handle:httpCall(
          "lua_cluster",
          {
           [":method"] = "POST",
           [":path"] = "/acl",
           [":authority"] = "internal.org.net"
          },
         "authorize call",
         5000)
       end
1 Like

You are right, I tried other configuration, it is the same.