Inter-service communication between pods in micro service applications.

In Micro-services applications major problem is establishing the communication between one service pod to another service pod across the namespaces.  

How to achieve this issue? Here is the solution.   

If the web service and the app-service are in different namespaces, we cannot communicate as Kubernetes doesn’t communicate across namespaces. We cannot use just service names like web-app-service as they are valid only within the namespace. So, how do we communicate across namespaces? Let’s see.  

Using fully-qualified DNS names  

Kubernetes has the solution for this problem. If we have a cluster DNS service like CoreDNS running, we can use fully qualified DNS names (FQDN). Our web-server is running in namespace test-namespace and has a service web-app-service defined. We can address this using the URL shown below:  

Web-app-service.test-namespace.svc.cluster.local  

Breakdown of the URL  

  1. .cluster.local : This is the root of our cluster DNS; every resource must be accessed from the root.  
  2. .svc : This tells us we are accessing a service resource.  
  3. test-namespace : This is the namespace where our web-app-service is defined.  
  4. web-app-service: This is our service name. 

We can use URLs like http://web-app-service.test-namespace.svc.cluster.local:[portnumber] ignore port if the service is mapping default HTTP port 80)  

So the general format for addressing service in another namespace is to use a fully qualified DNS(FQDN). It is always suitable to use URLs like this as they are universal and can be addressable anywhere throughout the cluster.   

General format of the URL:  
{{service_name}}.{{namespace}}.svc.cluster.local  

This is the solution to communication between pods. 

Cloud Engineer

Gabriel Chutuape

A technology enthusiast passionate about automation, Gabriel Chutuape is a Cloud Engineer at ISmile Technologies. He’s part of the ISmile Technologies Cloud enablement team that help customers to design/solution/project engineering, integrating and implementing infrastructure technologies & services.

CLOUD Engineer

Gopi Krishna

I’m working as Cloud DevOps Engineer. Expertise in technologies of Kubernetes, cloud services and cloud-native services, and DevOps technologies in various clouds.

Register a Free Cloud ROI Assesment Workshop

Register a Free Cloud ROI Assesment Workshop

Get a Detailed assessment report with recommendations with an assessment report

Schedule free Workshop
Register a Free Cloud ROI Assesment Workshop
Register a Free Cloud ROI Assesment Workshop

Related articles you may would like to read

Leveraging Data Management Maturity Model to boost data management capabilities

Request a Consultation