Hary
Hary

Reputation: 1218

Microservice registration with Eureka replicas in docker swarm cluster

If I have a microservice for Eureka service discovery and I have 5 replicas for it in docker-compose.yml then, these 5 eureka containers would be spread across multiple swarm nodes available in swarm cluster.

My question is, when a microservice wants to register itself with eureka,

  1. Would it specify the ip address of the master node in the swarm cluster in its config for eureka server ?

  2. When a microservice registers itself with eureka whichever way, does this registry get replicated across all the eureka containers in swarm cluster as who know which eureka node in swarm cluster would service a particular microservice.

Upvotes: 2

Views: 1902

Answers (1)

Ser
Ser

Reputation: 2900

When a microservice registers itself with eureka whichever way, does this registry get replicated across all the eureka containers

Never tested by myself, but I think this happens. Registries contact themself and share all current registred microservices from everywhere.

who know which eureka node in swarm cluster would service a particular microservice

Your microservice has an unique name in its application.properties that allows others microservices to send it an HTTP request, you don't control that mechanism in java so I hope it contacts the most suitable.

Would it specify the ip address of the master node in the swarm cluster in its config for eureka server ?

I tryed several times to setup an hostname to let microservice contacts eureka using a container based hostname but that doesn't work. I use frolvlad/alpine-oraclejdk8 as base image + bash and wait-for-it.sh. I run everything with docker-compose.
Keep in mind that this is the configuration server that tells microservices where is eureka. I endup to add a bash script in the configuration server to extract the application.properties from the jar file, put the IP of the registry, and rewrite the updated application.properties into the jar.

Upvotes: 1

Related Questions