库伯内斯 | AWS-EKS |无法解析主机名

Kubernetes | AWS-EKS | could not resolve host name

我创建了四个服务,两个 ClusterIP 和两个 NodePort 服务。针对每项服务,我启动了两个容器,如下所示。

但是,问题是有些服务工作正常,有些在从容器内部调用时无法解析服务主机名。

在缩小问题范围的同时,我创建了一个下面的矩阵:-

TYPES   NodePort    ClusterIp
NodePort    Pass    Fail
ClusterIp   Pass    Fail

which explains:-

  1. 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.
  2. In the same way, calling of nodeport service from another nodeport container works.
  3. But, calling of clusterIP service from a ClusterIp container fails and not able to resolve the hostname.

令人惊讶的是,集群 IP 容器能够解析 Nodeport 服务的主机名,并且从同一个 nodePort 容器遍历回同一个 ClusterIp 服务是行不通的。

如有任何建议,我们将不胜感激。我被这个问题困了四天多了。

这是 pods 的详细信息,服务和端点也工作正常。

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                        

谢谢

问题出在有端口冲突的代码中。用于从 Nodeport 重定向到 ClusterIp 的那个不正确。