<p>If I have 2 pods is there a way for them to talk to each other without any other resource created and used?</p>

<p>The question goes for the both situations - if they are in the same namespace or in different ones.</p>

<p>Yes, they can!</p>

<p>Assuming you don't have any network policies restricting the calls, it just need to know its DNS name, this is how it works:</p>

<ul>
<li>the cluster must have DNS enabled</li>
<li>if the pods are manually create on the same namespace(not via deployment), you just need make a call to the podname that act as the host.

<ul>
<li>POD1 running on namespace NS1 exposing the container port 31333</li>
<li>POD2 running on namespace NS1 </li>
<li>POD2 call POD1 via <a href="http://POD1:31333" rel="nofollow noreferrer">http://POD1:31333</a></li>
</ul></li>
<li>if the pods are on different namespaces, you need to include the namespace to the host.

<ul>
<li>POD1 running on namespace NS1 exposing the container port 31333</li>
<li>POD2 running on namespace NS2 </li>
<li>POD2 call POD1 via <a href="http://POD1.NS1:31333" rel="nofollow noreferrer">http://POD1.NS1:31333</a></li>
</ul></li>
<li>if the pod is being created by a deployment, it's name is dynamic, is hard to predic, in this case, you need a service to expose the pods to others by using a common name(the service)

<ul>
<li>DEPLOYMENT1 deployed to namespace NS1 will create a pod with following format deploymentname-hash(example: DEPLOYMENT1-f82hsh)</li>
<li>DEPLOYMENT1-f82hsh is the pod created by the deployment and is running on namespace NS1, created exposing the container port 31333</li>
<li>POD2 running on namespace NS2 </li>
<li>POD2 could call DEPLOYMENT1-f82hsh via <a href="http://DEPLOYMENT1-f82hsh.NS1:31333" rel="nofollow noreferrer">http://DEPLOYMENT1-f82hsh.NS1:31333</a>, but because the name is dynamic, at any time it could change to something else and break POD2</li>
<li>The solution is deploy service SVC1 that forward requests to DEPLOYMENT1 pods</li>
<li>POD2 then call <a href="http://SVC1:31333" rel="nofollow noreferrer">http://SVC1:31333</a> that will forward the call to DEPLOYMENT1-f82hsh or whatever pod is available in the DEPLOYMENT1.</li>
</ul></li>
</ul>

<p>The scenarios above assume you <strong>haven't</strong> set the hostname neither subdomain in the pod and is using the default configuration.</p>

<p>In more advanced scenarios you would also use the cluster dns suffix to call these services. The following docs describes everything in more details
<a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/</a></p>
