<p>I have a 'UI' and an 'API' microservice that I'm deploying on k8s default namespace with Istio enabled. My k8s environment is a dev box and doesn't have an External Load Balancer.</p>
<p>The UI's port configuration is 80(service port):80(container port in pod).<br />
The API's port configuration is 8000(service port):80(container port in pod)</p>
<p>I have to expose both these microservices for external traffic, since some people might use the 'UI' and some people might directly call the 'API' (via postman) for their requests.</p>
<p>When these microservices were running as simple docker containers without the k8s layer, users directly used the <code>host.example.com</code> for UI and <code>host.example.com:8000/api</code> for API calls (API calls are JSON-RPC).</p>
<p>I have a Gateway and VirtualService set up for both these microservices:</p>
<p>For UI:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: ui-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
servers:
- port:
    number: 80
    name: http
    protocol: HTTP
  hosts:
    - host.example.com
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ui-vs
spec:
  hosts:
  - host.example.com
  gateways:
  - ui-gateway
  http:
  - route:
    - destination:
      port:
        number: 80
      host: ui --&gt; name of k8s svc
</code></pre>
<p>For API:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: api-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - host.example.com
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: api-vs
spec:
  hosts:
  - host.example.com
  gateways:
  - api-gateway
http:
- route:
  - destination:
      host: api -&gt; name of api service
      port:
        number: 8000
</code></pre>
<p>Now going by the Istio documentation (<a href="https://istio.io/latest/docs/tasks/traffic-management/ingress/ingress-control/#accessing-ingress-services-using-a-browser" rel="nofollow noreferrer">accessing on browser</a>) to access this UI in the browser I need to access it via <code>${INGRESS_HOST}:${INGRES_PORT}</code>. In my case:</p>
<pre><code>INGRESS_HOST=host.example.com
INGRESS_PORT=31165
</code></pre>
<p>So accessing <a href="http://host.example.com:31165" rel="nofollow noreferrer">http://host.example.com:31165</a> loads the UI, how do I now access the API microservice externally on <code>host.example.com</code> via Postman etc? The 8000 API port is not accessible from outside. I guess it all has to go via 31165, but what route do I need to use to access the API directly? What changes do I need to do for this, if any, in my set-up? I have just started with Istio.</p>

user1452759
<p>one option is to add a host header.</p>
<p>an easier way for local dev stuff is to use a <code>*.nip.io</code> address.</p>
<p>If your ingress got an IP (look for an external IP in the result of <code>k get svc -n istio-system istio-ingressgateway</code>), then that's what you would use in the url.</p>
<p>e.g.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: grafana-virtualservice
  namespace: monitoring
spec:
  gateways:
  - grafana-gateway
  hosts:
  - grafana.192.168.87.2.nip.io
  http:
  - route:
    - destination:
        host: kube-prometheus-stack-grafana
</code></pre>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:  
  name: grafana-gateway
  namespace: monitoring
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - grafana.192.168.87.2.nip.io
    port:
      name: http
      number: 80
      protocol: HTTP
</code></pre>
<p>HTTPS redirects work too if you create a certificate</p>
<p>e.g.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: argocd-gateway
  namespace: argocd
spec:
  selector:
    istio: ingressgateway
  servers:
    - hosts:
        - argocd.192.168.87.2.nip.io
      port:
        name: http
        number: 80
        protocol: HTTP
      tls:
        httpsRedirect: true
    - hosts:
        - argocd.192.168.87.2.nip.io
      port:
        name: https
        number: 443
        protocol: HTTPS
      tls:
        credentialName: argocd.192.168.87.3.nip.io
        mode: SIMPLE
</code></pre>
