Docker swarm - create a single service elasticsearch 3 node cluster

I’m trying to create a single service Elasticsearch 3 node cluster. I cannot set the cluster.initial_master_nodes environment variable appropriately.
I’m using:

redhat 7 server
docker Version: 17.09.0-ce

The below EFK.yml deploys successfully but cannot determine the master-eligible nodes.

version: "3.3"
services:
  elasticsearch:
    image: repository.net/efk/elasticsearch-7-12-1
    environment:
      - node.name=node.{{.Task.Slot}}
      - discovery.seed_hosts=tasks.elasticsearch
      - discovery.type=zen
      - network.host=0.0.0.0
      - cluster.name=k-test-cluster
      - cluster.initial_master_nodes=node.1,node.2,node.3
      - node.ml=false
      - bootstrap.memory_lock=false
      - "ES_JAVA_OPTS=-Xms8192m -Xmx8192m"
      - xpack.security.enabled=true
      - ELASTIC_PASSWORD=changeIt
    ports:
      - 9200
      - 9300
    networks:
      - private
    volumes:
      - /opt/mount1/elasticsearch/data:/usr/share/elasticsearch/data
      - /opt/mount1/elasticsearch/logs:/usr/share/elasticsearch/logs
    deploy:
      mode: global
      placement:
        constraints: [node.role == worker]

To deploy:
docker stack deploy -c EFK.yml EFK

Warming error message:

{"type": "server",  
"timestamp": "2021-09-28T11:26:18,867Z",  
"level": "WARN",  
"component": "o.e.c.c.ClusterFormationFailureHelper",  
"cluster.name": "k-test-cluster",  
"node.name": "node.qvf6m2d81mypjiv5ndvgq7ph6",  
<b>"message": "master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster,  
and this node must discover master-eligible nodes </b> 
[node.1, node.2, node.3] to bootstrap a cluster: have discovered <br> [{node.qvf6m2d81mypjiv5ndvgq7ph6}{1fOzv5V7SdebaX2ECmd2rQ}{zk_287GXSGSuPV4mCT2diw}{10.0.0.4}{10.0.0.4:9300}{cdfhimrstw}  
{xpack.installed=true, transform.node=true}, <br> {node.98apd4okuoqu8ezjdw24j97ih}{tLwF0Tr1TtOfT2jNuGp1tA}{VphiDK9IQGS6CJG1Mfltrw}{10.0.0.4}{10.0.0.4:9300}{cdfhimrstw}  
{xpack.installed=true, transform.node=true}, 
{node.wfyhphmldrccpptjn8wxvlup0}{OG_VB4nlSFmZYkrJYIoyoA}{-Ku2biybQmalTyhRPe37mQ}{10.0.0.4}{10.0.0.4:9300}{cdfhimrstw}  
{xpack.installed=true, transform.node=true}];  
discovery will continue using [10.0.0.7:9300, 10.0.0.5:9300, 10.0.0.6:9300] from hosts providers and <br> [{node.qvf6m2d81mypjiv5ndvgq7ph6}{1fOzv5V7SdebaX2ECmd2rQ}{zk_287GXSGSuPV4mCT2diw}{10.0.0.4}{10.0.0.4:9300} {cdfhimrstw}  
{xpack.installed=true, transform.node=true}]  
from last-known cluster state; node term 0, last-accepted version 0 in term 0" }

You need to ensure that the nodes have predictable names and then set them in the cluster.initial_master_nodes property.

Docker Swarm is a good fit for stateless things but Elasticsearch is very much not stateless so you might encounter various problems going down this path.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.