# Is it possible pods talk to each other in

**URL:** <https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379>\
**Category:** General Discussions\
**Created:** [October 18, 2019, 4:34pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379 "2019-10-18T16:34:50Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpmolinamatute](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jpmolinamatute/32/3867_2.png) [@jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)\
**Post date:** [October 18, 2019, 4:34pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/1 "2019-10-18T16:34:50Z")

</div>

Hello World

I have a deployment with a replica more than one pod and a service type of NodePort. The goal is that I can scale up/down the number of pods during run time. So far I can see that each pod got its own hostname, however, they don’t see each other. The question is, how can I make each pod see each other??

---

<div class="post-metadata">

**Author:** ![thockin](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thockin/32/2457_2.png) [@thockin](https://discuss.kubernetes.io/u/thockin)\
**Post date:** [October 18, 2019, 4:51pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/2 "2019-10-18T16:51:48Z")

</div>

What environment are you using? A cloud? Bare metal? DIY? What are you doing for networking?

Pods are supposed to be able to reach each other, that is the fundamental requirement. If that is broken, everything else will be broken, too.

---

<div class="post-metadata">

**Author:** ![jpmolinamatute](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jpmolinamatute/32/3867_2.png) [@jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)\
**Post date:** [October 18, 2019, 5:17pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/3 "2019-10-18T17:17:51Z")

</div>

Hi @thockin

I’m using AWS EKS, for the networking I’m using default configuration.  
One thing to clarify the service can talk to another services as expected but the problem that I’m having is that the pods inside of this service (or deployment) cannot talk to each other

---

<div class="post-metadata">

**Author:** ![thockin](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thockin/32/2457_2.png) [@thockin](https://discuss.kubernetes.io/u/thockin)\
**Post date:** [October 18, 2019, 5:55pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/4 "2019-10-18T17:55:32Z")

</div>

> ![](https://us1.discourse-cdn.com/flex016/uploads/kubernetes/original/2X/c/c55e5a43ed9320f324affe2e9c76cd8af290dbc2.jpeg "jpmolinamatute")  
> [jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)
> 
> ```
> October 18
> 
> ```
> 
> Hi [@thockin](https://discuss.kubernetes.io/u/thockin)

> I’m using AWS EKS, for the networking I’m using default configuration.
> 
> One thing to clarify the service can talk to another services as expected but the problem that I’m having is that the pods inside of this service (or deployment) cannot talk to each other

What does this mean SPECIFICALLY? If you ping from one pod to another pod by IP address - it doesn’t work?

---

<div class="post-metadata">

**Author:** ![jpmolinamatute](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jpmolinamatute/32/3867_2.png) [@jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)\
**Post date:** [October 18, 2019, 8:35pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/5 "2019-10-18T20:35:45Z")

</div>

I just changed from a deployment to a StatefulSet and created two separate services. but I still have the same problem. I can’t reach other pods by hostname

interesting enough I can ping by IP address from one pod to another.

```
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: nifi
  labels:
    app: nifi
spec:
  serviceName: nifi
  replicas: 3
  template:
    metadata:
      labels:
        app.kubernetes.io/name: nifi-node
        app.kubernetes.io/instance: nifi-instance
    spec:
      containers:
        - name: nifi
          imagePullPolicy: Always
          image: xxxxxxxxxxxxx.dkr.ecr.us-east-2.amazonaws.com/nifi
          ports:
            - containerPort: 8080
              name: nifi-http
            - containerPort: 8082
              name: nifi-node
---
apiVersion: v1
kind: Service
metadata:
  name: nifi-web
  labels:
    app: nifi
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: nifi-node
    app.kubernetes.io/instance: nifi-instance
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: nifi-http
---
apiVersion: v1
kind: Service
metadata:
  name: nifi
  labels:
    app: nifi
spec:
  clusterIP: None
  selector:
    app.kubernetes.io/name: nifi-node
    app.kubernetes.io/instance: nifi-instance
  ports:
    - name: tcp
      protocol: TCP
      port: 8082
      targetPort: nifi-node
```

---

<div class="post-metadata">

**Author:** ![acim](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/acim/32/1955_2.png) [@acim](https://discuss.kubernetes.io/u/acim)\
**Post date:** [October 18, 2019, 9:17pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/6 "2019-10-18T21:17:31Z")

</div>

Why should replicated pods “see” each other? Which hostname do you use to check this? I mean in pod A how do you try to connect to pod B, using which hostname? And another thing is, do you have some network policy?

---

<div class="post-metadata">

**Author:** ![thockin](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thockin/32/2457_2.png) [@thockin](https://discuss.kubernetes.io/u/thockin)\
**Post date:** [October 18, 2019, 9:19pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/7 "2019-10-18T21:19:57Z")

</div>

Pods don’t generally have DNS resolvable names. That’s what Services are for. There are some affordances for this, but they are the exception, rather than the rule. Why do you want to resolve an individual pod?

---

<div class="post-metadata">

**Author:** ![jpmolinamatute](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jpmolinamatute/32/3867_2.png) [@jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)\
**Post date:** [October 19, 2019, 12:17am UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/8 "2019-10-19T00:17:59Z")

</div>

Hi @acim

I’m working on a [cluster zero master](https://docs.cloudera.com/HDPDocuments/HDF3/HDF-3.4.1.1/nifi-configuration-best-practices/content/zero-master-clustering.html)

in my pod I executer the `hostname` command and pass it to nifi, then each instance of nifi talk to zookeeper announcing itself at the same time each nifi instance read each other hostname from zookeeper.

then each instance of nifi fails because cannot reach other instances.

I don’t have a network policy

---

<div class="post-metadata">

**Author:** ![jpmolinamatute](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jpmolinamatute/32/3867_2.png) [@jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)\
**Post date:** [October 19, 2019, 12:20am UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/9 "2019-10-19T00:20:46Z")

</div>

is there a way to resolve each hostname from within each pod?

I’m working on [cluster zero master](https://docs.cloudera.com/HDPDocuments/HDF3/HDF-3.4.1.1/nifi-configuration-best-practices/content/zero-master-clustering.html) and I want to be able to scale up and down “workers”

---

<div class="post-metadata">

**Author:** ![thockin](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thockin/32/2457_2.png) [@thockin](https://discuss.kubernetes.io/u/thockin)\
**Post date:** [October 19, 2019, 1:52am UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/10 "2019-10-19T01:52:26Z")

</div>

If you set the pod hostname and subdomain AND that subdomain is the name of a headless Service, you will get resolvable names, but be aware that in a replica set, Al replicas have the same name, so you need a statefulset or something else.

---

<div class="post-metadata">

**Author:** ![acim](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/acim/32/1955_2.png) [@acim](https://discuss.kubernetes.io/u/acim)\
**Post date:** [October 19, 2019, 8:52am UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/11 "2019-10-19T08:52:43Z")

</div>

You can’t find other pod names unless you ask apiserver or something like zk. What kind of names do you get from zk? Do you get IP addresses from other pods?

---

<div class="post-metadata">

**Author:** ![jpmolinamatute](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jpmolinamatute/32/3867_2.png) [@jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)\
**Post date:** [October 19, 2019, 7:35pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/12 "2019-10-19T19:35:37Z")

</div>

Hi @thockin

I think we are on the right track however I’m a little confused about how FQDN is in Kubernetes/pod, I set a subdomain to match the same as the headless service and then I found [this article](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id) about how FQDN is formed but this made me more confused than before.

this is the information that I have:

Namespace: bigdata  
Headless Service: nifi-domain  
StatefulSet: nifi-worker  
Pod: nifi-worker-{0…3}  
subdomain: nifi-domain

how can I build a resolvable name?

is it nifi-domain.bigdata.svc.nifi-domain? or is it nifi-domain.bigdata.svc.cluster.local?

thanks for the help! 🙂

---

<div class="post-metadata">

**Author:** ![jpmolinamatute](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jpmolinamatute/32/3867_2.png) [@jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)\
**Post date:** [October 19, 2019, 7:46pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/13 "2019-10-19T19:46:09Z")

</div>

Hi @acid

a nifi instance gets whatever other nifi instances announce themself to ZK. so the flow is like this:

I have three pods with and their hostname are nifi-worker-1, nifi-worker-2 and nifi-worker-3. All of them announce themselves using those names to ZK. Then nifi-worker-1 gets a worker hostname, in this case, nifi-worker-3, then nifi-worker-1 tries to communicate to nifi-worker-3 but it fails because it cannot reach it.

if I do `kubectl describe pod/nifi-worker-x` I can see that each pod gets its own IP address, then I login into any of the worker pod and do a ping to an IP address of the other workers, it works!

---

<div class="post-metadata">

**Author:** ![acim](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/acim/32/1955_2.png) [@acim](https://discuss.kubernetes.io/u/acim)\
**Post date:** [October 19, 2019, 8:36pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/14 "2019-10-19T20:36:39Z")

</div>

[https://v1-13.docs.kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pods](https://v1-13.docs.kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pods)

If this is not going to work for you, I suggest to read IP addresses from Zookeeper, not hostnames. Zk must have IP addresses as well.

---

<div class="post-metadata">

**Author:** ![thockin](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thockin/32/2457_2.png) [@thockin](https://discuss.kubernetes.io/u/thockin)\
**Post date:** [October 19, 2019, 9:53pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/15 "2019-10-19T21:53:51Z")

</div>

> ![](https://us1.discourse-cdn.com/flex016/uploads/kubernetes/original/2X/c/c55e5a43ed9320f324affe2e9c76cd8af290dbc2.jpeg "jpmolinamatute")  
> [jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)
> 
> ```
> October 19
> 
> ```
> 
> Hi [@thockin](https://discuss.kubernetes.io/u/thockin)

> I think we are on the right track however I’m a little confused about how FQDN is in Kubernetes/pod, I set a subdomain to match the same as the headless service and then I found [this article](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id) about how FQDN is formed but this made me more confused than before.

> this is the information that I have:

> Namespace: bigdata
> 
> Headless Service: nifi-domain
> 
> StatefulSet: nifi-worker
> 
> Pod: nifi-worker-{0…3}
> 
> subdomain: nifi-domain

> how can I build a resolvable name?

X = Pod hostname (not pod name - there is a hostname field.

Y = Pod subdomain

Z = Namespace name

X.Y.Z.sv.cluster.local

---

<div class="post-metadata">

**Author:** ![jpmolinamatute](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/jpmolinamatute/32/3867_2.png) [@jpmolinamatute](https://discuss.kubernetes.io/u/jpmolinamatute)\
**Post date:** [October 20, 2019, 4:05pm UTC](https://discuss.kubernetes.io/t/is-it-possible-pods-talk-to-each-other-in/8379/16 "2019-10-20T16:05:28Z")

</div>

it worked!! thanks!!! 🙂
