I have a VirtualService that splits traffic between an internal Service and an external ServiceEntry, based on HTTP route prefix.
The external service requires HTTPS traffic.
I test routes using curl like below:
curl https://my-service.domain.com/internal-route -> should go to internal service
curl https://my-service.domain.com/external-route -> should go to external service
What I tried so far:
- Use HTTP routes for both internal and external service.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
spec:
gateways:
- ...
hosts:
- my-service.domain.com
http:
- match:
- uri:
prefix: /internal-route
route:
- destination:
host: my-service.my-ns.svc.cluster.local
- match:
- uri:
prefix: /external-route
route:
- destination:
host: external-service.otherdomain.com
---
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
spec:
hosts:
- external-service.otherdomain.com
ports:
- number: 443
name: https
protocol: HTTP
location: MESH_EXTERNAL
resolution: DNS
When I try this, the external service indicates that HTTP traffic is being sent to its HTTPS port (443). This makes sense, since Istio is terminating the TLS connection and using HTTP to forward the request to the external service.
- Using a "tls" match type (for external service) and "http" route (for internal service) within the same VirtualService.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
spec:
gateways:
- ...
hosts:
- my-service.domain.com
http:
- match:
- uri:
prefix: /internal-route
route:
- destination:
host: my-service.my-ns.svc.cluster.local
tls:
- match:
- port: 443
sniHosts:
- my-service.domain.com
route:
- destination:
host: external-service.otherdomain.com
---
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
spec:
hosts:
- external-service.otherdomain.com
ports:
- number: 443
name: https
protocol: TLS
location: MESH_EXTERNAL
resolution: DNS
This results in Istio returning a HTTP 404 when I try to reach a route that should go to the external service.
- Same as above, with ServiceEntry
protocol
set to HTTP instead of TLS.
How can I configure Istio to terminate the TLS connection and then use HTTPS (via a new TLS connection) to send traffic to the external service?
EDIT 1:
I found in the Istio docs (one and two) that this should be possible by adding a DestinationRule
, but this does not seem to have any effect.
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: tls-foo
spec:
host: external-service.otherdomain.com
trafficPolicy:
portLevelSettings:
- port:
number: 80
tls:
mode: SIMPLE