Hi all,
I’m attempting to streamline the migration of some legacy applications into Istio by creating ServiceEntries and namespace-scoped VirtualServices pointing at different legacy environments. Specifically, I’m trying to get it so curl http://auth
when ran on a container in namespace dev
goes to auth.dev-legacy-service.com
while the same command when run on a container in the namespace test
goes to auth.test-legacy-service.com
. My understanding is that this can be done with a combination of ServiceEntries and VirtualServices. The configuration I’ve got now is as follows:
2 ServiceEntries, in the default
namespace, implicitly exportingTo: “*”:
---
kind: ServiceEntry
apiVersion: networking.istio.io/v1alpha3
metadata:
name: legacy-auth-dev
namespace: default
spec:
hosts:
- auth.dev-legacy-system.com
location: MESH_EXTERNAL
ports:
- number: 80
name: http
protocol: HTTP
- number: 443
name: https
protocol: HTTPS
---
kind: ServiceEntry
apiVersion: networking.istio.io/v1alpha3
metadata:
name: legacy-auth-test
namespace: default
spec:
hosts:
- auth.test-legacy-system.com
location: MESH_EXTERNAL
ports:
- number: 80
name: http
protocol: HTTP
- number: 443
name: https
protocol: HTTPS
A VirtualService in the dev
namespace, explicitly exportingTo: .
---
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
name: legacy-auth-dev
namespace: dev
spec:
hosts:
- auth
exportTo:
- "."
http:
- timeout: 10s
route:
- destination:
host: auth.dev-legacy-system.com
weight: 100
A VirtualService in the test
namespace explicitly exportingTo: .
---
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
name: legacy-auth-test
namespace: test
spec:
hosts:
- auth
exportTo:
- "."
http:
- timeout: 10s
route:
- destination:
host: auth.test-legacy-system.com
weight: 100
After creating these and waiting a few minutes, I run the curl from a container inside the dev
namespace:
$ curl -v http://auth
* Rebuilt URL to: http://auth/
* Could not resolve host: auth
* Closing connection 0
curl: (6) Could not resolve host: auth
Same result when run from a container in the test
namespace. However if I use the full addresses and curl http://auth.dev-legacy-system.com
it works fine. Calling kubectl describe
on the relevant resources shows that everything is in place.
Am I missing something simple, or is this simply the wrong approach? It may not be relevant, but I’m running this on GKE version 1.13.6-gke.5 which appears to be running Istio 1.1.3.
And on a related note, if everything was working, what would happen to the Host header in the case of an HTTPS connection? Would it show the new “short name” and thus potentially break any routing on the external service’s side that uses the Host header to dispatch requests?
Thanks!