我正在部署一个简单的web应用程序。我把它分成3个pod:前端、后端和postgres db。每一个都有服务。我分别为前端和后端创建了LoadBalancer服务。我的postgres db pod的ClusterIP服务。我的前端是html/javascript/angularjs/jquery。后端是基于泽西岛的后端和postgres之间的Java web services.Connection工作得很好,因为我从浏览器测试它。请看下面的内容。但是,当我试图从我的前端访问相同的login web服务调用时,它没有work.Please,如下所示。我的后端和前端没有错误消息,我的本地计算机(Eclispe Jee+Tomcat),一切正常,因为前端和后端驻留在同一台logs.In服务器上。所以我的问题是,我能从google kubernetes的LoadBalancer服务中调用LoadBalancer服务吗?在我的前端后端pods上抛出了某些错误,但它是自发出现的,而不是在我的web服务调用之后。我在这里放了我的部署信息postgres pod。后端和前端部署与它非常相似,只是添加了LoadBalancer作为类型。How to access postgresql pod/service in google kubernetes
//The following call on browser to my web service works.
http://23.34.23.34:8080/LocWebService/rest/authorize/admin1
//The following call from my front end does not work on google kubernetes
$http.get("http://23.34.23.34:8080/LocWebService/rest/
authorize/"+$scope.Name)
//The following spontaneous error is thrown on my front end and back end
pods.
[http-nio-8080-exec-3] org.apache.coyote.http11.Http11Processor.service
Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged
at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method
name. HTTP method names must be token发布于 2019-07-19 00:31:04
从技术上讲,您的前端pods应该能够调用您的后端pods的外部IP,并且应该能够到达它们。但是,更好的选择是让前端pods使用服务的ClusterIP调用后端pods (与后端调用DB的方式相同)。您仍然可以将服务类型保留为LoadBalancer,以防您希望直接公开后端。
至于为什么您的特定情况不起作用,我们需要更多的日志或错误消息来查看数据包发生了什么。
从理论上讲,应该发生的事情是:
Pod => LB外部IP =>到达节点IP表=>转发到后端pod
现在,数据包实际上不会通过本地节点的iptables,它将立即获得DNATed并转发到正确的后端pod。我之前看到的一个可能的问题是,后端pod期望来自外部源的流量,由于流量实际上没有到达外部LB IP,因此没有使用外部IP作为源,因此应用程序不会接受它。
https://stackoverflow.com/questions/57097721
复制相似问题