I am learning Spring boot kubernetes and trying to setup spring cloud gateway for my services. I believe with Spring cloud gateway we don;t have to use ribbon for load balancing any more. So If I don;t use ribbon then the configuration for routes changes as well. I looked over the sites for suggestion and following is what I found :-
routes:
- id: department_route
uri: http://departmentservice:4200 #
predicates:
- Path=/*
In this case the uri has a hardcoded value of port at which the service is available. Is this is recommended approach ?
And then there is another flavor of the configuration which looks like this and Not sure what url-expression trying to do :-
spring:
application.name: gateway
cloud:
gateway:
discovery:
locator:
enabled: true
url-expression: "'http://'+serviceId"
server.port: 8080
Is it not possible to do a service discovery by name and append the predicate after that?
I am Still working on fixing the Spring Cloud Gateway project of main but following has worked for me. I have configured the routes via Zuul so make sure your dependencies and configuration related to it matches :-
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
**Config :: application.yaml ::**
zuul:
routes:
shopping-cart-service:
path: "/shopping-cart-service/**"
item-service:
path: "/item-service/**"