Kubernetes - Communicate between namspaces and services

3/1/2019

I have a pod running in namespace X under Service A. I have a pod running a REST API in namespace Y under Service B.

How do i set up this communication?

Thank you.

-- Jaspreet Singh
cluster-computing
docker
kubernetes
namespaces
service

1 Answer

3/1/2019

Simply use the full name of the service.

<TARGET_SERVICE_NAME>.<TARGET_NAMESPACE_NAME>.svc.cluster.local

Now using your example :

curl B.Y.svc.cluster.local

RESPONSE FROM THE SERVICE B IN NAMESPACE Y

It will work from anywhere in the cluster but is dependent to the namespace.


You can also use external name which is a bit more complicated but should deal with your problem too.

-- Doctor
Source: StackOverflow