Lua filter
Adds the new x-header: test header to all outgoing HTTP requests to service offers
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshProxyPatch
metadata:
name: backend-lua-filter
namespace: kong-mesh-system
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: MeshService
name: mesh-gateway_gateways_svc
default:
appendModifications:
- httpFilter:
operation: AddBefore
match:
name: envoy.filters.http.router
origin: outbound
listenerTags:
kuma.io/service: offers
value: |-
name: envoy.filters.http.lua
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
inline_code: |
function envoy_on_request(request_handle)
request_handle:headers():add("x-header", "test")
end
type: MeshProxyPatch
mesh: default
name: backend-lua-filter
spec:
targetRef:
kind: MeshService
name: mesh-gateway_gateways_svc
default:
appendModifications:
- httpFilter:
operation: AddBefore
match:
name: envoy.filters.http.router
origin: outbound
listenerTags:
kuma.io/service: offers
value: |-
name: envoy.filters.http.lua
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
inline_code: |
function envoy_on_request(request_handle)
request_handle:headers():add("x-header", "test")
end
Please adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_proxy_patch" "backend_lua_filter" {
provider = konnect-beta
type = "MeshProxyPatch"
name = "backend-lua-filter"
spec = {
target_ref = {
kind = "MeshService"
name = "mesh-gateway_gateways_svc"
}
default = {
append_modifications = [
{
http_filter = {
operation = "AddBefore"
match = {
name = "envoy.filters.http.router"
origin = "outbound"
listener_tags = {
kuma.io/service = "offers"
}
}
value = "name: envoy.filters.http.lua
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
inline_code: |
function envoy_on_request(request_handle)
request_handle:headers():add("x-header", "test")
end"
}
}
]
}
}
labels = {
"kuma.io/mesh" = konnect_mesh.my_mesh.name
}
cp_id = konnect_mesh_control_plane.my_meshcontrolplane.id
mesh = konnect_mesh.my_mesh.name
}