We can create a knative service which have two revisions, then we can config traffic like this.
traffic:
- latestRevision: false
percent: 100
revisionName: header-v1
- latestRevision: false
percent: 0
revisionName: header-v2
tag: v2
We can use header "Knative-Serving-Tag: v2" to route to header-v2 revision. However, we want to route to specific revision using custom header, like "User: v2". What should we do? We tried some method. First, we try to edit the corresponding virtualservice, but the new rules will be automatically deleted. Then, we try to add a new virtualservice.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: header-custom-ingress
namespace: default
spec:
gateways:
- knative-serving/knative-ingress-gateway
hosts:
- header-test.default.XXXXXXXXXXXXXXX.io
http:
- match:
- headers:
User:
exact: v2
retries: {}
rewrite:
authority: v2-header.default.XXXXXXXXXXXXXXX.io
route:
- destination:
host: istio-ingressgateway.istio-system.svc.cluster.local
port:
number: 80
weight: 100
Hosts cannot be the same as the previous one, otherwise it will not take effect. We don't want to change the host, we just want to route through the custom header. What would be the better way to do that? Thanks in advance.