Let's consider we have three environments:
test.website.comdev.website.comprod.website.comEach of the environment consists of the following microservices: webapp, service1, service2. I want to be able to easily call all the services from JS frontend without having to deal with domains. It would be great if I could just call /services/service1/ and the fact I am on the same domain would keep me in the same environment.
So let's consider dev environment:
dev.website.com/ -> goes to webappdev.website.com/services/service1/ -> goes to service1dev.website.com/services/service1/ ...To be able to do that, I configured ingress as follows:
- path: /services/service1/*
backend:
serviceName: service1
servicePort: 8080
- path: /services/service2/*
backend:
serviceName: service2
servicePort: 8080
- path: /*
backend:
serviceName: webapp
servicePort: 8080This would work great, but it doesn't.
service1 receives full path (/services/service1) instead of just / when being called. For that I found this: ingress.kubernetes.io/rewrite-target: / - But I also foudn that this feature is not implemented, which is contradictory and doesn't make much sense./services/service1/ ends up in webapp.Is this even a good approach? What is the best practice to do this?
Edit:
According to suggestions I removed * from the path, which helped, but also removed necessary functionality. I need to be able to use:
/en/ -> webapp/services/service1/method1 -> service1This doesn't work without the * in path.
According to the documentation of nginx-ingress, the annotation prefix is now nginx.ingress.kubernetes.io and not ingress.kubernetes.io as you used. You can change it with the argument --annotations-prefix.
Try to remove the wildcard (*) from your path:
- path: /service/service1
backend:
serviceName: service1
servicePort: 8080
- path: /service/service2
backend:
serviceName: service2
servicePort: 8080
- path: /
backend:
serviceName: webapp
servicePort: 8080