I am doing a POC on simple microservices architecture using typical Spring cloud stack but instead of Eureka server, service discovery is to be made using spring-cloud-kubernetes which is not working.
The whole POC is here - https://github.com/dhananjay12/spring-microservices-using-spring-kubernetes
Gateway as a edge server and 2 downstream services- user-service and contact-us-service.
The k8 setup is in k8s folder.
The downstream services have following dependencies:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
application.yml
server:
port: 8100
management:
endpoints:
web:
exposure:
include: '*'
spring:
cloud:
kubernetes:
enabled: true
reload:
enabled: true
eureka:
client:
enabled: false
bootstrap.yml:
spring:
application:
name: user-service
and annotation of @EnableDiscoveryClient
in the main class.
The gateway service has too relevant kubernetes dependencies:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-ribbon</artifactId>
</dependency>
application.yml
server:
port: 8050
spring:
application:
name: gateway
cloud:
kubernetes:
enabled: true
reload:
enabled: true
gateway:
discovery:
locator:
lowerCaseServiceId: true
enabled: true
eureka:
client:
enabled: false
logging:
level:
root: DEBUG
org.springframework.gateway: TRACE
org.springframework.cloud.gateway: TRACE
org.springframework.cloud.loadbalancer: TRACE
management:
endpoints:
web:
exposure:
include: '*'
bootstrap.yml
spring:
application:
name: gateway
and annotation of @EnableDiscoveryClient
in the main class.
Please see the deployment and service yaml here - https://github.com/dhananjay12/spring-microservices-using-spring-kubernetes/tree/master/k8s
I am able to get to gateway but it is not routing to downstream service like user-service:
For example - /user-service/users/getPublicMailingAddress
gives Whitable error page
and the logs in gateway shows:
2019-07-07 06:40:30.017 TRACE 1 --- [or-http-epoll-2] o.s.c.g.h.p.RoutePredicateFactory : Pattern "[/my-nginx-nginx-ingress-controller/**]" does not match against value "/user-service/users/getPublicMailingAddress"