I created four services, two ClusterIP and two NodePort services. Against each service I spin up two containers as shown below.
However, the problem is some services work fine and some while calling from inside the container not able to resolve the service hostname.
While narrowing down a problem, I created a below matrix:-
TYPES NodePort ClusterIp
NodePort Pass Fail
ClusterIp Pass Fail
which explains:-
- A request (curl –v http://order-service-ip/swagger/index.html) from inside the container of aggregator-service(nodePort) fails and throws could not resolve hostname error but vice-versa works. That is hitting a request (curl –v http://aggregator-service/swagger/index.html) from inside the container of order-service-ip works.
- In the same way, calling of nodeport service from another nodeport container works.
- But, calling of clusterIP service from a ClusterIp container fails and not able to resolve the hostname.
Surprisingly, a cluster IP container is able to resolve the hostname of Nodeport service and traversing back from the same nodePort container to the same ClusterIp service does not work.
Any suggestions are appreciated. I am stuck with this problem for more than four days now.
Here are the details of pods and services and end points are also working fine.
NAME ........ READY STATUS
nodeport-aggegator-deployment-64497699d-6jqz4 1/1 Running
nodeport-aggegator-deployment-64497699d-jx8n6 1/1 Running
clusterip-order-deployment-ip-594ff6b59b-pb4bp 1/1 Running
clusterip-order-deployment-ip-594ff6b59b-rbhj4 1/1 Running
nodeport-resources-deployment-6b98d47b5b-qvd59 1/1 Running
nodeport-resources-deployment-6b98d47b5b-zjrh7 1/1 Running
clusterip-product-deployment-ip-7589c74bfc-dx8l4 1/1 Running
clusterip-product-deployment-ip-7589c74bfc-mbqs5 1/1 Running
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
aggregator-service NodePort 10.100.66.74 <none> 8081:30392/TCP,443:30891/TCP
order-service-ip ClusterIP 10.100.118.19 <none> 8010/TCP,443/TCP
resources-service NodePort 10.100.81.65 <none> 8001:31076/TCP,443:30429/TCP
product-service-ip ClusterIP 10.100.66.14 <none> 8011/TCP,443/TCP
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP
Thanks
The problem was with in a code which had a port conflict. The one being used to redirect from Nodeport to ClusterIp was not correct.