I have an application named metadata
running in EKS, which serves traffic on /api
. The service of metadata
configuration is as follows:
Service Configuration:
spec:
ports:
- name: web
port: 80
protocol: TCP
targetPort: 8080
selector:
app: metadata
type: ClusterIP
This application has Swagger configured, and I am using Istio as the ingress controller. I have created a VirtualService for this service as shown below:
VirtualService Configuration:
- match:
- uri:
prefix: "/metadata/"
- uri:
prefix: "/metadata"
rewrite:
uri: "/"
route:
- destination:
host: metadata.core.svc.cluster.local
port:
number: 80
The desired URL should be like: https://example.com/metadata/, and Istio should rewrite this and route to the pod on /api.
This works as expected when I use Traefik as the ingress controller. However, with Istio, I am facing an issue. When accessing the Swagger UI URL in the browser at https://example.com/metadata/swagger-ui, it works initially. But when I try to test some API from the UI, it trims the base path and creates the request URL as https://example.com/api/request instead of https://example.com/metadata/api/request.
Note: Its working when i try the same test with curl command.
My issue is similar to this question, but I do not want to change my code because the same code is used in other environments where Traefik is the controller.