<p>I'm trying to migrate from ingress to istio gateway + virtual service routing, but I keep receiving a <code>404 Not Found</code> error.</p>
<p>The only link that the app should be accessed to is using <code>my-todos.com</code>, configured locally.</p>
<p>What am I missing here?</p>
<p>Note: the ingress controller works just fine. Initially, <code>todo-lb.default.svc.cluster.local</code> in the <code>istio.yaml</code> file was just set to <code>todo-lb</code>, representing the configured load balancer, still with no success.</p>
<p>Here is the <code>ingress.yaml</code> file (to migrate from):</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: todo-ingress
spec:
  rules:
    - host: my-todos.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: todo-lb
                port:
                  number: 3001
          - path: /api
            pathType: Prefix
            backend:
              service:
                name: {{ .Values.api.apiName }}
                port:
                  number: {{ .Values.api.apiPort }}
</code></pre>
<p>Here is the <code>istio.yaml</code> file (to migrate TO):</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: todo-istio-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - my-todos.com
    # - &quot;*&quot;
    tls:
      httpsRedirect: true
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      credentialName: tls-secret
    hosts:
    - my-todos.com
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: todo-lb
spec:
  hosts:
  - my-todos.com
  # - &quot;*&quot;
  gateways:
  - todo-istio-gateway
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: todo-lb.default.svc.cluster.local
        port:
          number: 3001
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: todo-api
spec:
  hosts:
  - my-todos.com
  # - &quot;*&quot;
  gateways:
  - todo-istio-gateway
  http:
  - match:
    - uri:
        prefix: /api
    route:
    - destination:
        host: {{ .Values.api.apiName }}
        port:
          number: {{ .Values.api.apiPort }}
</code></pre>

<p>From what I see you've wrong gateway configuration in your virtual service, that's why it might not work.</p>
<hr />
<p>If gateway is  not in the same namespace as virtual service, you have to specify that in virtual service</p>
<p>Check the <code>spec.gateways</code> section</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: bookinfo-Mongo
spec:
  gateways:
  - some-config-namespace/my-gateway # can omit the namespace if gateway is in same
                                       namespace as virtual service.
</code></pre>
<hr />
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
  namespace: some-config-namespace
</code></pre>
<p>There is related  <a href="https://istio.io/docs/reference/config/networking/gateway/" rel="nofollow noreferrer">istio documentation</a> about that.</p>
<hr />
<p>So please move your todo-istio-gateway to default namespace.</p>
<p>or use</p>
<pre><code>gateways:
  - istio-system/todo-istio-gateway
</code></pre>
<hr />
<p>Few things to check if that won't help:</p>
<ul>
<li>Is your app deployed in default namespace?</li>
<li>Is your app <a href="https://istio.io/latest/docs/setup/additional-setup/sidecar-injection/#injection" rel="nofollow noreferrer">injected</a>?</li>
</ul>
