I have two services running on minikube, Foo and Bar. When I'm accessing the Foo service it makes a request to Bar service to retrieve some data. Bar service have 2 versions "1.0" and "2.0". I have setup the default RouteRule configuration with istio to route all the requests to "1.0":
apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
name: bar-default
spec:
destination:
name: bar-server
precedence: 1
route:
- labels:
version: "1.0"It works fine, and I can see that all the requests is forwarded to "1.0". Now I want to add another RouteRule based on the headers, so all the requests from Chrome browser will be forwarded to "2.0":
apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
name: bar-v2
spec:
destination:
name: bar-server
precedence: 2
match:
request:
headers:
user-agent:
regex: ".*Chrome.*"
route:
- labels:
version: "2.0"And it doesn't work. All the requests are still routed to "1.0". I can see that the RouteRule is created:
> istioctl get routerules
NAME KIND NAMESPACE
bar-default RouteRule.v1alpha2.config.istio.io default
bar-v2 RouteRule.v1alpha2.config.istio.io defaultI can see in the developers tools in browser that the UserAgent header is present. How can I debug the request to see why doesn't it get forwarded to "2.0"?
It could be that your Foo service does not pass the User-Agent header that it gets from the browser.
Additional check would be to perform a curl call to Bar from Foo by kubectl exec and to check that version 2.0 is called when passing it the User-Agent header:
curl -H "user-agent: ---Chrome---" bar-server
You can either install curl in your Foo container, or use a separate container with curl, like this one from Istio samples