<p>I am new to istio and I want to expose three services and route traffic to those services based on the port number passed to &quot;website.com:port&quot; or subdomain.</p>
<p>services  deployment config files:</p>
<pre><code>    apiVersion: v1
kind: Service
metadata:
  name: visitor-service 
  labels:
    app: visitor-service
spec:
  ports:
    - port: 8000
      nodePort: 30800
      targetPort: 8000
  selector:
   app: visitor-service
---   
apiVersion: apps/v1
kind: Deployment
metadata:
  name: visitor-service 
spec:
  replicas: 1
  selector:
    matchLabels:
      app: visitor-service
  template:
    metadata:
      labels:
        app: visitor-service
    spec:
      containers:
        - name: visitor-service
          image: visitor-service
          ports:
            - containerPort: 8000
</code></pre>
<p>second service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: auth-service 
  labels:
    app: auth-service
spec:
  ports:
    - port: 3004
      nodePort: 30304
      targetPort: 3004
  selector:
   app: auth-service
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: auth-service
  template:
    metadata:
      labels:
        app: auth-service
    spec:
      containers:
        - name: auth-service
          image: auth-service
          ports:
            - containerPort: 3004
</code></pre>
<p>Third one:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: gateway 
  labels:
    app: gateway
spec:
  ports:
    - port: 8080
      nodePort: 30808
      targetPort: 8080
  selector:
   app: gateway

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gateway
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gateway
  template:
    metadata:
      labels:
        app: gateway
    spec:
      containers:
        - name: gateway
          image: gateway
          ports:
            - containerPort: 8080
</code></pre>
<p>If someone can help setting up the gateway and virtual service configuration it would be great.</p>

Abdnacer Fried
<p>It seems like you simply want to expose your applications, for that reason istio seems like a total overkill since it comes with a lot of overhead that you won't be using.
Regardless of whether you want to use istio as your default ingress or any other ingress-controller (nginx, traefik, ...) the following construct applies to all of them:
Expose the ingress-controller via a service of type <code>NodePort</code> or <code>LoadBalancer</code>, depending on your infrastructure. In a cloud environment the latter one will most likely work the best for you (if on GKE, AKS, EKS, ...).
Once it is exposed set up a DNS A record to point to the external IP address. Afterwards you can start configuring your ingress, depending on which ingress-controller you chose the following YAML may need some adjustments (example is given for istio):</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: istio
  name: ingress
spec:
  rules:
  - host: httpbin.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          serviceName: httpbin
          servicePort: 8000
</code></pre>
<p>If a request for something like <code>httpbin.example.com</code> comes in to your ingress-controller it is going to send the request to a service named <code>httpbin</code> on port <code>8000</code>.
As can be seen in the YAML posted above, the <code>rules</code> and <code>paths</code> field take a list (indicated by the <code>-</code> in the next line). To expose multiple services simply add a new entry to the list, e.g.:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: istio
  name: ingress
spec:
  rules:
  - host: httpbin.example.com
    http:
      paths:
      - path: /httpbin
        pathType: Prefix
        backend:
          serviceName: httpbin
          servicePort: 8000
      - path: /apache
        pathType: Prefix
        backend:
          serviceName: apache
          servicePort: 8080
</code></pre>
<p>This is going to send requests like <code>httpbin.example.com/httpbin/</code> to <code>httpbin</code> and <code>httpbin.example.com/apache/</code> to <code>apache</code>.</p>
<p>For further information see:</p>
<ul>
<li><a href="https://istio.io/latest/docs/tasks/traffic-management/ingress/kubernetes-ingress/" rel="nofollow noreferrer">https://istio.io/latest/docs/tasks/traffic-management/ingress/kubernetes-ingress/</a></li>
<li><a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/ingress/</a></li>
</ul>
