According to Istio documentation I should be able to use an arbitrary name in VirtualService
’s hosts
field:
Virtual service hosts don’t actually have to be part of the Istio service registry, they are simply virtual destinations.
Unfortunately, I don’t seem to be able to get this working. Here my example:
- I have two services called
webapp1
andwebapp2
. Both in namespacemynamespace
- I would like to be able to send a request to
http://foo.mynamespace/
that will get routed towebapp1
. Note that there is no service calledfoo
.
Here my VirtualService
configuration:
...
spec:
hosts:
- webapp1.mynamespace.svc.cluster.local
- webapp2.mynamespace.svc.cluster.local
- foo.mynamespace.svc.cluster.local
http:
- route:
- destination:
host: webapp1.mynamespace.svc.cluster.local
port:
number: 80
My understanding is that the above should route all of the following requests to webapp1
service:
http://webapp1.mynamespace/
http://webapp2.mynamespace/
http://foo.mynamespace/
What I see is that both requests to http://webapp1.mynamespace/
and http://webapp2.mynamespace/
get routed to webapp1
service.
However, requests to http://foo.mynamespace/
result in name resolution error (executed from a container in the Istio mesh):
curl http://foo.mynamespace/
curl: (6) Could not resolve host: foo.mynamespace
Any thoughts on what I’m missing?