404 Not Found when migrating from ingress to istio 404 Not Found when migrating from ingress to istio kubernetes kubernetes

404 Not Found when migrating from ingress to istio


From what I see you've wrong gateway configuration in your virtual service, that's why it might not work.


If gateway is not in the same namespace as virtual service, you have to specify that in virtual service

Check the spec.gateways section

apiVersion: networking.istio.io/v1alpha3kind: VirtualServicemetadata:  name: bookinfo-Mongospec:  gateways:  - some-config-namespace/my-gateway # can omit the namespace if gateway is in same                                       namespace as virtual service.

apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata:  name: my-gateway  namespace: some-config-namespace

There is related istio documentation about that.


So please move your todo-istio-gateway to default namespace.

or use

gateways:  - istio-system/todo-istio-gateway

Few things to check if that won't help:

  • Is your app deployed in default namespace?
  • Is your app injected?


In addition to @Jakub answer, there can be one more reason you can get 404 error. Your current ingress rules in virtual service looks like this:

HostnamePathRoute
my-todos.com/Forward to todo-lb.default.svc.cluster.local
my-todos.com/apiForward to {{ .Values.api.apiName }}

In Istio, each of the above is an ingress rule. If in Istio ingress-gateway, the rules are added in the above order, then all the URL path including the prefix /api gets routed to the first service i.e. todo-lb.default. It is better to create a single Virtual service like this and then see if the routing works as expected.

apiVersion: networking.istio.io/v1alpha3kind: VirtualServicemetadata:  name: todo-apispec:  hosts:  - my-todos.com  gateways:  - <namespace>/todo-istio-gateway  http:  - match:    - uri:        prefix: /api    route:    - destination:        host: {{ .Values.api.apiName }}        port:          number: {{ .Values.api.apiPort }}  - match:    - uri:        prefix: /    route:    - destination:        host: todo-lb.default        port:          number: 3001