I created a rule to redirect all requests which has specified header but the rule has no effect.
My rule :
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
name: reviews
namespace: spiro--bookinfo-dev
spec:
hosts:
- reviews
http:
- match:
headers:
version:
exact: v1
route:
- destination:
host: reviews
subset: v1
- match:
- headers:
version:
exact: v3
route:
- destination:
host: reviews
subset: v3
- route:
- destination:
host: reviews
port:
number: 9080
To add the header i use an EnvoyFilter :
kind: EnvoyFilter
apiVersion: networking.istio.io/v1alpha3
metadata:
name: reviews
namespace: spiro--bookinfo-dev
spec:
workloadSelector:
labels:
app: reviews
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
patch:
operation: INSERT_BEFORE
value:
name: envoy.lua
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
inlineCode: |
function envoy_on_request(request_handle)
request_handle:headers():add("version", "v1")
end
I checked that it is added to request in istio-proxy :
headers_encoded::authority:reviews:9080&:path:/reviews/0&:method:GET&user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) … ;URI=spiffe://cluster.local/ns/spiro–bookinfo-dev/sa/default&version:v1
Does header rule works for internal services ?