How to properly route requests in istio virtual service?

6/22/2021

I have the following services running in Minikube on istio. These services are deployed in the default namespace which istio-injection enabled.

categories-api      ClusterIP   10.99.4.33       <none>        80/TCP    60m
justshop-api        ClusterIP   10.98.187.253    <none>        80/TCP    60m
manufacturers-api   ClusterIP   10.106.134.195   <none>        80/TCP    60m
products-api        ClusterIP   10.108.139.67    <none>        80/TCP    60m
reviews-api         ClusterIP   10.97.18.230     <none>        80/TCP    60m
taxes-api           ClusterIP   10.96.17.129     <none>        80/TCP    60m

From the above services, justshop-api is the service that receives traffic from the gateway on port 80. It then routes traffic to the appropriate service based on the path specified

Examples: http://<host>:<port>/products --- This route respond with 200 ok http://<host>:<port>/products/10 --- This fails with internal service error.

Same with other routes.

Here is my yaml file

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: default-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: justshop-virtual-service
spec:
  hosts:
    - "*"
  gateways:
    - istio-system/default-gateway
  http:
  - route:
    - destination:
        host: justshop-api
          subset: v1
        weight: 100
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: justshop-destination-rule
spec:
  host: justshop-api
  subsets:
    - name: v1
      labels:
        version: v1.0.0

I tried various combinations using prefix and regex paths in the virtual service. But nothing works. The above services were developed in SpringBoot.

Can someone help me resolve this?

Regards Raj

-- Rajasekar
istio
kubernetes
routes

0 Answers