Skip to content

Virtual Gateway

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: default-ns-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      hosts:
        - "*.example.com"

Virtual Service

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginx
spec:
  gateways:
    - default-ns-gateway
  hosts:
    - nginx.example.com
  http:
    - match:
        - uri:
            prefix: /
      route:
        - destination:
            host: nginx
            port:
              number: 80

Virtual Gateway and Virtual Service doesn't work if non-standard ports are used. In that case, use authority: exact in the VirtualService. If the host is accessible in 8433 port, then use the following Gateway and VirtualSerivce settings

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: default-ns-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      hosts:
        - "*"

---

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginx
spec:
  gateways:
    - default-ns-gateway
  hosts:
    - "*"
  http:
    - match:
        - authority:
            exact: nginx.example.com:8443
      route:
        - destination:
            host: nginx
            port:
              number: 80