Elasticsearch 7.x setup on kubernetes

5/1/2020

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 ?

-- avadhut007
elasticsearch-7
kubernetes

1 Answer

5/1/2020

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"
-- avadhut007
Source: StackOverflow