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:
Breakdown of the URL
- .cluster.local : This is the root of our cluster DNS; every resource must be accessed from the root.
- .svc : This tells us we are accessing a service resource.
- test-namespace : This is the namespace where our web-app-service is defined.
- 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:
This is the solution to communication between pods.
Read this E-Book to get a pulse on Elasticsearch monitoring.
Are you monitoring your Elasticsearch environment to detect problems like unreliable nodes and out-of-memory errors? Know which metrics to monitor & where to start.
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.
I’m working as Cloud DevOps Engineer. Expertise in technologies of Kubernetes, cloud services and cloud-native services, and DevOps technologies in various clouds.