<p>Allow two pods (say pod A and B) running in same/different namespace communicate irrespective of the protocol(say http,https,akka.tcp) along with a valid Network policy applied.</p>

<p><strong><em>Solutions tried:</em></strong></p>

<ol>
<li><p>Tried applying network policy to both the pods and also used the service name: “my-svc.my-namespace.svc.cluster.local” to make pod B
communicate to pod A which is running the service “my-svc” but both
failed to communicate.</p></li>
<li><p>Also tried adding the IP address and host mapping of pod A in pod B while it’s deployment, then pod B was able to communicate to pod A
but inverse communication is failing.</p></li>
</ol>

<p>Kindly suggest me a way to fix this.</p>

<p>By default, pods can communicate with each other by their IP address, regardless of the namespace they're in.</p>

<p>You can see the IP address of each pod with:</p>

<pre><code>kubectl get pods -o wide --all-namespaces
</code></pre>

<p>However, the normal way to communicate within a cluster is through Service resources.</p>

<p>A Service also has an IP address and additionally a DNS name. A Service is backed by a set of pods. The Service forwards requests to itself to one of the backing pods.</p>

<p>The fully qualified DNS name of a Service is:</p>

<pre><code>&lt;service-name&gt;.&lt;service-namespace&gt;.svc.cluster.local
</code></pre>

<p>This can be resolved to the IP address of the Service from anywhere in the cluster (regardless of namespace).</p>

<p>For example, if you have:</p>

<ul>
<li>Namespace <code>ns-a</code>: Service <code>svc-a</code> → set of pods A</li>
<li>Namespace <code>ns-b</code>: Service <code>svc-b</code> → set of pods B</li>
</ul>

<p>Then a pod of set A can reach a pod of set B by making a request to:</p>

<pre><code>svc-b.ns-b.svc.cluster.local
</code></pre>
