<p>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</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>  elasticsearch.yml: |-
    cluster.name: ${CLUSTER_NAME}
    cluster.initial_master_nodes: elasticsearch-0


    network.host: 0.0.0.0</code></pre>
</div>
</div>
</p>

<p>But after applying files, second node is not joining the elastic cluster</p>

<p>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}</p>

<p>How to solve this ?</p>

avadhut007
<p>I used following env variable for container in Statefulset yaml and it worked.</p>

<pre><code>      - 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"
</code></pre>
