Hi Team,
I am trying to add multiple matches with multiple rewrites in my virtual service. Could you please suggest?
My virtual service as below -
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
annotations:
helm.fluxcd.io/antecedent: default:helmrelease/hello-11
creationTimestamp: "2020-10-15T11:52:02Z"
generation: 2
name: hello-11
namespace: default
resourceVersion: "4178089"
selfLink: /apis/networking.istio.io/v1beta1/namespaces/default/virtualservices/hello-11
uid: kfk9580d-0fedc-11eb-b8a2-pp155d6a1e13
spec:
gateways:
- istio-system/istio-ingressgateway
- istio-system/istio-ingressgateway
hosts:
- ext-auth-host
- no-ext-auth-host
http:
- gateways:
- istio-system/istio-ingressgateway
match:
- headers:
x-jwt-extracted-xx-id:
exact: "9980098"
name: hello-11-ext-auth
route:
- destination:
host: hello-11.default.svc.cluster.local
- gateways:
- istio-system/istio-ingressgateway
headers:
request:
add:
x-jwt-extracted-xx-id: "9980098"
match:
- uri:
prefix: /9980098/api/show
name: hello-11-no-ext-auth
rewrite:
uri: /api/show
route:
- destination:
host: hello-11.default.svc.cluster.local
I am trying to add the below 2 Uri rewrite for 2 different request match.
uri: /api/send
uri: /api/show
Expected Virtual service should -
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
annotations:
helm.fluxcd.io/antecedent: default:helmrelease/hello-11
creationTimestamp: "2020-10-15T11:52:02Z"
generation: 2
name: hello-11
namespace: default
resourceVersion: "4178089"
selfLink: /apis/networking.istio.io/v1beta1/namespaces/default/virtualservices/hello-11
uid: kfk9580d-0fedc-11eb-b8a2-pp155d6a1e13
spec:
gateways:
- istio-system/istio-ingressgateway
- istio-system/istio-ingressgateway
hosts:
- ext-auth-host
- no-ext-auth-host
http:
- gateways:
- istio-system/istio-ingressgateway
match:
- headers:
x-jwt-extracted-xx-id:
exact: "9980098"
name: hello-11-ext-auth
route:
- destination:
host: hello-11.default.svc.cluster.local
- gateways:
- istio-system/istio-ingressgateway
headers:
request:
add:
x-jwt-extracted-xx-id: "9980098"
match:
- uri:
prefix: /9980098/api/show
name: hello-11-no-ext-auth
rewrite:
uri: /api/show
route:
- destination:
host: hello-11.default.svc.cluster.local
match:
- uri:
prefix: /9980098/api/send
name: hello-11-no-ext-auth
rewrite:
uri: /api/send
route:
- destination:
host: hello-11.default.svc.cluster.local
Thanking you in anticipation.
Regards
Manoj