Override discovery.type=single-node in docker-compose.yml

I'm using two -c yaml files on the docker-compose command line to provide override of Elasticsearch settings. I have the base settings in docker-compose.yml in the services.elasticsearch.environment, and the override in docker-compose.multi.yml.

The base file settings are for a single-node elasticsearch deployment, so include discovery.type=single-node. What config parameter can I use in docker-compose.multi.yml to override this discovery type and do a multi-node

base:

environment:
  - cluster.name=cluster_name
  - network.host=0.0.0.0
  - ELASTIC_PASSWORD=${BOOTSTRAP_PASSWORD}
  - node.name={{.Node.Hostname}}
  - xpack.security.enabled=true
  - discovery.type=single-node

multi override:

environment:
  - discovery.seed_hosts=elasticsearch
  - cluster.initial_master_nodes=$INITIAL_MASTER_NODES
  - xpack.security.transport.ssl.enabled=true
  - xpack.security.transport.ssl.verification_mode=certificate
  - xpack.security.transport.ssl.certificate_authorities=$CERTS_DIR/ca/ca.crt
  - xpack.security.transport.ssl.certificate=$CERTS_DIR/instance/instance.crt
  - xpack.security.transport.ssl.key=$CERTS_DIR/instance/instance.key
  - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

I tried discover.type=multi-node, and then also tried leaving discovery.type out of the override as I've shown here.
With multi-node ES complains about unknown type.
Without an override discovery.type I get this error

setting [cluster.initial_master_nodes] is not allowed when [discovery.type] is set to [single-node]

Is there a discovery.type setting that can override single-node value to work with multi-node deployment?

Answering my own question: probably not.
I have not been able to find the documentation for discovery.type anywhere, does anyone have a link?

But, as you may have guessed, it's easy to get around this without a discovery.type override.
Here's what I did:

base:

environment:
- xpack.security.transport.ssl.enabled=true

multi-override:

environment:
- discovery.seed_hosts=elasticsearch
- cluster.initial_master_nodes=$INITIAL_MASTER_NODES

single-node override:

environment:
- discovery.type=single-node

deploy stack single-node:
docker stack deploy -c base.yml -c single.yml stack_name

deploy stack multi-node:
docker stack deploy -c base.yml -c multi.yml stack_name

The docs for discovery.type are here; you should either set it to single-node or not set it at all.

Note also that you should only set cluster.initial_master_nodes the first time the cluster is forming; on a restart or when adding new nodes you shouldn't set this.

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