apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: BACKEND
  namespace: istio-system
spec:
  hosts:
  - https.secure.com
  addresses:
  - 1.1.1.2
  ports:
  - number: 15004
    name: HTTPS
    protocol: https
  location: MESH_INTERNAL
  resolution: STATIC
  endpoints:
  - address: 1.2.3.4
  exportTo:
  - '*'
---
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: istio-ingressgateway
  namespace: istio-system
spec:
  hosts:
  - istio-ingressgateway.istio-system.svc.cluster.local
  addresses:
  - 1.1.1.3
  ports:
  - number: 80
    name: http
    protocol: HTTP
  - number: 443
    name: https
    protocol: HTTPS
  location: MESH_INTERNAL
  resolution: STATIC
  exportTo:
  - '*'
  endpoints:
  - address: 99.1.1.1
    labels:
      istio: ingressgateway
---
# Ingress gateway spec
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: istio-ingressgateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*.bookinfo.com"
    tls:
      httpsRedirect: true # sends 302 redirect for http requests
  - port:
      number: 443
      name: https
      protocol: HTTPS
    hosts:
    - "*.bookinfo.com"
    tls:
      mode: SIMPLE
      serverCertificate: /etc/certs/servercert.pem
      privateKey: /etc/certs/privatekey.pem
  - port:
      number: 443
      name: https-passthru
      protocol: HTTPS
    hosts:
    - https.secure.com
    tls:
      mode: PASSTHROUGH
  - port:
      number: 443
      name: tls-passthru
      protocol: TLS
    hosts:
    - tls.secure.com
    tls:
      mode: PASSTHROUGH
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: bookinfo
  namespace: istio-system
spec:
  hosts:
  - "*.bookinfo.com"
  gateways:
  - istio-system/istio-ingressgateway
  http:
  - route:
    - destination:
        host: www.bookinfo.com
        port:
          number: 80
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: https
  namespace: istio-system
spec:
  hosts:
  - https.secure.com
  gateways:
  - istio-system/istio-ingressgateway
  tls:
  - match:
    - sniHosts:
      - https.secure.com
    route:
    - destination:
        host: https.secure.com
        port:
          number: 443
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: tls
  namespace: istio-system
spec:
  hosts:
  - tls.secure.com
  gateways:
  - istio-system/istio-ingressgateway
  tls:
  - match:
    - sniHosts:
      - tls.secure.com
    route:
    - destination:
        host: https.secure.com
        port:
          number: 443
---
