<p>I'm a beginner in Kubernetes and I have a situation as following: I have two differents Pods: <strong>PodA</strong> and <strong>PodB</strong>. Firstly, I want to expose <strong>PodA</strong> to the outside world, so I create a <strong>Service</strong> (type NodePort or LoadBalancer) for <strong>PodA</strong>, which is not difficult to understand for me. </p>

<p>Then I want <strong>PodA</strong> communicate to <strong>PodB</strong>, and after several hours googling, I found the answer is that I also need to create a <strong>Service</strong> (type ClusterIP if I want to keep <strong>PodB</strong> <em>only visible</em> inside the cluster) for <strong>PodB</strong>, and if I do so, I can let <strong>PodA</strong> and <strong>PodB</strong> comminucate to each other. But the problem is I also found <a href="https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-networking-guide-beginners.html" rel="noreferrer">this article</a>. According to this webpage, they say that <a href="https://i.stack.imgur.com/6PdHj.gif" rel="noreferrer"><em>the communication between pods on the same node</em></a> can be done via <code>cbr0</code>, a <strong>Network Bridge</strong>, or <a href="https://i.stack.imgur.com/rEkB6.gif" rel="noreferrer"><em>the communication between pods on different nodes</em></a> can be done via a <code>route table</code> of the cluster, and they don't mention anything to the <strong>Service</strong> object (which means we don't need <strong>Service</strong> object ???). </p>

<p>In fact, I also read the documents of K8s and I found in the <a href="https://kubernetes.io/docs/concepts/cluster-administration/networking/" rel="noreferrer">Cluster Networking</a> </p>

<blockquote>
  <p><strong>Cluster Networking</strong><br>
  ...<br> 
  2. Pod-to-Pod communications: this is the primary focus of this document.<br>
  ...<br></p>
</blockquote>

<p>where they also focus on to the <strong>Pod-to-Pod communications</strong>, but there is no stuff relevant to the <strong>Service</strong> object.</p>

<p>So, I'm really confusing right now and my question is: Could you please explain to me the connection between these stuff in <a href="https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-networking-guide-beginners.html" rel="noreferrer">the article</a> and the <strong>Service</strong> object? The <strong>Service</strong> object is a high-level abstract of the <code>cbr0</code> and <code>route table</code>? And in the end, how can the <strong>Pods</strong> can communicate to each other?</p>

<p>If I misunderstand something, please, point it out for me, I really appreciate that. </p>

<p>Thank you guys !!!</p>

<p>Motivation behind using a service in a Kubernetes cluster.</p>

<p>Kubernetes Pods are mortal. They are born and when they die, they are not resurrected. If you use a Deployment to run your app, it can create and destroy Pods dynamically.</p>

<p>Each Pod gets its own IP address, however in a Deployment, the set of Pods running in one moment in time could be different from the set of Pods running that application a moment later.</p>

<p>This leads to a problem: if some set of Pods (call them “backends”) provides functionality to other Pods (call them “frontends”) inside your cluster, how do the frontends find out and keep track of which IP address to connect to, so that the frontend can use the backend part of the workload?</p>

<p>That being said, a service is handy when your deployments (podA and podB) are dynamically managed.</p>
