I am trying to setup elasticsearch 7.6.2 on kubernetes. I have created with statefulset with replica 2. I have setup elastic.yaml for configuration as following
elasticsearch.yml: |-
cluster.name: ${CLUSTER_NAME}
cluster.initial_master_nodes: elasticsearch-0
network.host: 0.0.0.0
But after applying files, second node is not joining the elastic cluster
ERROR: master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster, and this node must discover master-eligible nodes [elasticsearch-0] to bootstrap a cluster: have discovered [{elasticsearch-1}
How to solve this ?
I used following env variable for container in Statefulset yaml and it worked.
- name: cluster.name
value: k8s-logs
- name: node.name
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: discovery.seed_hosts
value: "es-cluster-0.elasticsearch,es-cluster-1.elasticsearch,es-cluster-2.elasticsearch"
- name: cluster.initial_master_nodes
value: "es-cluster-0,es-cluster-1,es-cluster-2"