# How to communicate between ELS Nodes using Kubernetes cluster with namespace and SVC

**URL:** <https://discuss.elastic.co/t/how-to-communicate-between-els-nodes-using-kubernetes-cluster-with-namespace-and-svc/236723>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Created:** [June 11, 2020, 2:37pm UTC](https://discuss.elastic.co/t/how-to-communicate-between-els-nodes-using-kubernetes-cluster-with-namespace-and-svc/236723 "2020-06-11T14:37:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Artur\_Drozdzyk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/artur_drozdzyk/32/45618_2.png) [@Artur\_Drozdzyk](https://discuss.elastic.co/u/Artur_Drozdzyk)\
**Post date:** [June 11, 2020, 2:37pm UTC](https://discuss.elastic.co/t/how-to-communicate-between-els-nodes-using-kubernetes-cluster-with-namespace-and-svc/236723/1 "2020-06-11T14:37:28Z")

</div>

I am trying to communicate between Elasticsearch nodes, so that the master node will be chosen in a voting. Unfortunately, nodes are not seeing eachother ( **discovery.seed\_hosts** ), despite of fact, that these are chained using headless service. Moreove, pods are defined within the same namespace.

Service definition:

```auto
kind: Service
apiVersion: v1
metadata:
  name: elasticsearch-scv
  namespace: elasticsearch-namespace
  labels:
    app: elasticsearch
spec:
  selector:
    app: elasticsearch
  clusterIP: None
  ports:
    - port: 9200
      name: rest
    - port: 9300
      name: inter-node

```

StatefulSet definition:

```auto
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: es-cluster
  namespace: elasticsearch-namespace
spec:
  serviceName: elasticsearch
  replicas: 3
  selector:
    matchLabels:
      app: elasticsearch
  template:
    metadata:
      labels:
        app: elasticsearch
    spec:
      containers:
      - name: elasticsearch
        image: docker.elastic.co/elasticsearch/elasticsearch:7.7.0
        resources:
            limits:
              cpu: 1000m
            requests:
              cpu: 100m
        ports:
        - containerPort: 9200
          name: rest
          protocol: TCP
        - containerPort: 9300
          name: inter-node
          protocol: TCP
        volumeMounts:
          - name: elasticsearch-persistent-storage
            mountPath: /usr/share/elasticsearch/data
        env:
          - 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"
          - name: node.max_local_storage_nodes
            value: "15"
          - name: ES_JAVA_OPTS
            value: "-Xms512m -Xmx512m"
          - name: node.max_local_storage_nodes
            value: "15"
      initContainers:
      - name: fix-permissions
        image: busybox
        command: ["sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"]
        securityContext:
          privileged: true
        volumeMounts:
        - name: elasticsearch-persistent-storage
          mountPath: /usr/share/elasticsearch/data
      - name: increase-vm-max-map
        image: busybox
        command: ["sysctl", "-w", "vm.max_map_count=262144"]
        securityContext:
          privileged: true
      - name: increase-fd-ulimit
        image: busybox
        command: ["sh", "-c", "ulimit -n 65536"]
        securityContext:
          privileged: true
      volumes:
        - name: elasticsearch-persistent-storage
          persistentVolumeClaim:
            claimName: elasticsearch-pvc

```

Namespace definition:

```auto
apiVersion: v1
kind: Namespace
metadata:
  name: elasticsearch-namespace
  labels:
    name: elasticsearch-namespace

```

@Edit

I have been trying to get the proper DNS using following commands:

```auto
k8 exec -it -n elasticsearch-namespace es-cluster-2 ping es-cluster-1.elasticsearch.elasticsearch-namespace.svc.es-cluster

k8 exec -it -n elasticsearch-namespace es-cluster-2 ping es-cluster-1.elasticsearch-scv.elasticsearch-namespace.svc.es-cluster

k8 exec -it -n elasticsearch-namespace es-cluster-2 ping es-cluster-1.elasticsearch.elasticsearch-scv.elasticsearch-namespace.svc.es-cluster

k8 exec -it -n elasticsearch-namespace es-cluster-2 ping es-cluster-1.elasticsearch.elasticsearch-namespace.svc.cluster.local

```

but I have found nothing at these addresses

@Edit2

CoreDNS output:

```auto
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          upstream
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
kind: ConfigMap
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"Corefile":".:53 {\n errors\n health\n kubernetes cluster.local in-addr.arpa ip6.arpa {\n pods insecure\n upstream\n fallthrough in-addr.arpa ip6.arpa\n }\n prometheus :9153\n forward . /etc/resolv.conf\n cache 30\n loop\n reload\n loadbalance\n}\n"},"kind":"ConfigMap","metadata":{"annotations":{},"labels":{"eks.amazonaws.com/component":"coredns","k8s-app":"kube-dns"},"name":"coredns","namespace":"kube-system"}}
  creationTimestamp: "2020-06-10T09:38:23Z"
  labels:
    eks.amazonaws.com/component: coredns
    k8s-app: kube-dns
  name: coredns
  namespace: kube-system
  resourceVersion: "171"
  selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
  uid: 20d7c02d-bkgt-11ea-hf54-0240aa367d4c

```

/etc/resolv.conf

```auto
nameserver 172.20.0.10
search elasticsearch-namespace.svc.cluster.local svc.cluster.local cluster.local eu-central-1.compute.internal
options ndots:5

```

@Edit3

```auto
04:10 PM :- macbook @ ~/Desktop/projects $ k8 exec -it -n elasticsearch-namespace es-cluster-2 ping es-cluster-1.elasticsearch.elasticsearch-namespace.svc.cluster.local
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.
ping: es-cluster-1.elasticsearch.elasticsearch-namespace.svc.cluster.local: Name or service not known
command terminated with exit code 2

```

Following URL does not work:  
`es-cluster-1.elasticsearch.elasticsearch-namespace.svc.cluster.local`

---

<div class="post-metadata">

**Author:** ![sebgl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebgl/32/48702_2.png) [@sebgl](https://discuss.elastic.co/u/sebgl)\
**Post date:** [June 12, 2020, 11:12am UTC](https://discuss.elastic.co/t/how-to-communicate-between-els-nodes-using-kubernetes-cluster-with-namespace-and-svc/236723/2 "2020-06-12T11:12:13Z")

</div>

> [@Artur\_Drozdzyk](#):
>
> `discovery.seed_hosts`

Is there a reason for you to set these? ECK already handles it for you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 4, 2022, 8:02am UTC](https://discuss.elastic.co/t/how-to-communicate-between-els-nodes-using-kubernetes-cluster-with-namespace-and-svc/236723/3 "2022-11-04T08:02:07Z")

</div>


