How do i serve multiple services in multiple ports?

Hi there very noobish question.

I setup a mails api service in minikube like this

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: mails-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      hosts:
        - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: mails-ingress
spec:
  hosts:
    - "*"
  gateways:
    - mails-gateway
  http:
    - route:
        - destination:
            host: mails

I am able to access it with : (PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}'))

But how do i add another different api service do i create another gateway ?
This service would not be directly related think mail.google and drive.google.
What is the recommended way to handle it?

Also i’m not quite sure i understand why the port:80 there. I see an example explosing 80 and 9080. But i’m not sure how would i acess the 9080 gateway because <minikubeip>:<ingress port> would access port 80

Hi,

you have a http service so you can use the “host” field to define on what name you want traffic to be routed to it.

Normally you would put a LoadBalancer in front of your istio-ingressgateway and use an dns entry for your LB. maybe with a wildcard like *.yourdomain.local so you can use any name you like, e.g. mailapi.yourdomain.local
If you are only workling locally, use something like dnsmasq to create wilddards for your minikube ip

Your Gateway would be only for your mail-service but could be used for multiple services, In each VirtualService you set a different “host” entry
The host-header in your http request is used to select the VirtualService in istio.