I am trying to set up the Eureka Server and use Netflix ribbon for client-side load balancing and I have used Spring Cloud's API Gateway to re-route the request. The API-gateway works fine when I run all microservices independently as Java application and ribbon is doing the client-side load balancing.
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("tracker", r -> r.path("/**")
.uri("lb://tracker") // Client side load balancing using Netflix Ribbon
)
.build();
}
and in my local API Eureka Server shows following:
Instances currently registered with Eureka
But when I try to orchestrate this using Kubernetes each microservice is unable to register them properly with Eureka Server due to which API gateway is unable to reroute the request.
This is the Eureka Screen when I am running Tracker Microservice in local.
I want to know do I need any extra configuration in order for this infrastructure to work or ma i missing anything.
Attaching my workloads.yaml
and services.yaml
file for reference.
https://github.com/neerajjain92/vehicle-position-simulator/tree/master/kubernetes
Snippet from workloads.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: eureka
spec:
selector:
matchLabels:
app: eureka
replicas: 1
template:
metadata:
labels:
app: eureka
spec:
containers:
- name: eureka
image: neerajjain/eureka
Snippet from services.yaml
apiVersion: v1
kind: Service
metadata:
name: gps-tracker-eureka-server
spec:
selector:
app: eureka
ports:
- port: 8761
nodePort: 30040
type: NodePort