Istio Multiple port number filed with single host

Viewed 128

Istio ingress gateway how to use multiple port field options number against with single hostname ip address.

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      name: nginx
      port: 80
      protocol: TCP
    hosts:
    - "https://ip-address1"
  - port:
      name: nodejs
      port: 449
      protocol: TCP
    hosts:
    - "https://ip-address1"
1 Answers

According to the Gateway documentation you need to define port as part of a single item of servers list. Within the very same item you specify hosts (as its name suggests you may specify here many different hosts, actually a list of them, as each one starts with a separate - sign).

If you want to specify one more port for the same host, you can simply repeat the name of this host within the context of another - port item like in the example here. It cannot be done in any different way than described in the official specification.

...
spec:
  selector:
    app: my-gateway-controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - uk.bookinfo.com
    - eu.bookinfo.com
    tls:
      httpsRedirect: true # sends 301 redirect for http requests
  - port:
      number: 443
      name: https-443
      protocol: HTTPS
    hosts:
    - uk.bookinfo.com
    - eu.bookinfo.com
    tls:
      mode: SIMPLE # enables HTTPS on this port
      serverCertificate: /etc/certs/servercert.pem
      privateKey: /etc/certs/privatekey.pem
...

As you can see above, same hosts are part of both http (port 80) and https (port 443) configurations.

Related