I have 3 node Elasticsearch cluster running as 3 docker services (1 task/container for each service ).
Docker-swarm is 2 node cluster. 1 Manager and 1 worker.
My java-app connects to one of the es1 node(docker container/service’s task) on transport port 9300 internally using this service(es1) Virtual IP (would have load-balance if this particular service had more replicas say 2 or 3) and thereby gets connected to 3 node ES cluster.
Likewise all three services task’s can be reached on the transport port 9300.
Now since this ES cluster and my java-app are deployed in the same overlay network and all containers/tasks are reachable to one and another.
So if this es1 service dies or i removed it and request comes from my java-app on es1, then would my java-app be able to get connected to either of the two remaining service’s task of ES cluster on port 9300, as all services(tasks/containers) can reached/ping each other being in the same Overlay network.
I have tried all i could think of. Didn’t succeed as of now. Don’t think it’s possible.
But anyway, Does docker-swarm network/load-balancer have this capability to switch request to one of the similar ES services all reachable on port 9300 internally in the same overlay network.
If yes, what exaclty needs to be included in the compose-file or which network to choose from.
Quick confirmation will be appreciated.
Here’s my ES cluster docker-compose file
version: '3.7'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.1
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- data01:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- elastic
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.1
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- data02:/usr/share/elasticsearch/data
networks:
- elastic
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.1
environment:
- node.name=es03
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- data03:/usr/share/elasticsearch/data
networks:
- elastic
volumes:
data01:
driver: local
data02:
driver: local
data03:
driver: local