Published on

Kubernetes Interacting with a Pod in Another Namespace

Authors

In Kubernetes when you need to interact with another pod the recommended and easiest way to do this from within the same namespace is via its service e.g. if pod-a had a service called service-a you could send a request to pod-a for example over http on port 80 (assuming that is how the service is configured) as follows: http://service-a.

Where it gets interesting is how do you refer to pod-b in pod-a if pod-b is in another namespace? It turns out Kubernetes has an approach for this. If pod-a is in namespace-a and pod-b is in namespace-b then you can refer to pod-b through its service: service-b.namespace-b.svc.cluster.local

There is a more detailed write up in the Kubernetes docs on how Kubernetes handles networking which can be found here.