1

We have Spring Boot service running in Kubernetes.
This service has endpoint:
- GET /healthz

We have liveness probe that uses this endpoint. Probe runs successfully.
It means that the endpoint is reachable from the service pod (localhost).

When I run in the service pod : wget https://localhost:8080/healthz I get an answer (OK)

When I try to call this endpoint outside the pod wget https://myhost:8080/healthz, I get response 400 without body.
I don't see any logs of Sprint. It seems that it does not reach the Sprint .
When I added flag -Djavax.net.debug=all I see in log that TLS handshake finished and then:

GET /healthz HTTP/1.1    
host: myhost:8080    
accept: application/json    
Connection: close     

and immediately

HTTP/1.1 400 
Transfer-Encoding: chunked
Date: Mon, 25 Jun 201 8 08:43:43 GMT
Connection: close

When I try wget https://myhost:8080/blahblah (non existing endpoint), I still get 400, not 404!

When I try wget https://myWronghost:8080/healthz (wrong host), I get an error Bad address. It means that host 'myhost' is correct (otherwise I would get this error).

Docker file:

FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENV JAVA_TOOL_OPTIONS -Dfile.encoding=UTF8
ENTRYPOINT ["java","-Djavax.net.debug=all", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
EXPOSE 8080

Summing up:
The service endpoints are accessible from within service pod, but not accessible from outside the pod.
Any idea why?

Update:
The problem was solved by calling the service with fully qualified domain name : serviceName.namespaceName.svc.cluster.local
Tomcat didn't accept calls with short domain serviceName.namespaceName, it responded 400.

4

4 回答 4

2

您的问题可能是由https://github.com/spring-projects/spring-boot/issues/13205引起的。您所要做的就是将 Tomcat 版本升级到 8.5.32。您可以通过在 pom.xml 文件中添加版本来做到这一点。

 <properties>
    <!-- your properties -->
    <tomcat.version>8.5.32</tomcat.version>
 </properties>
于 2018-07-11T10:57:14.553 回答
1

如果您使用的是 Spring boot 2,这可能是由于Tomcat 8.5.31中的错误导致 FQDN 的最后部分不允许使用“-”

将Tomcat 更新到 8.5.32 可以解决此问题。

参考:

于 2018-07-11T10:54:11.987 回答
0

不确定它在这里是否有任何影响,但你正在尝试一切https。你可以试试http吗?您的 spring 应用程序可能不支持端口 8080 上的 https。

于 2018-06-25T12:10:43.100 回答
0

通过使用完全限定的域名调用服务解决了该问题:
service-name.namespace-name.svc.cluster.local
该服务不接受使用service-name.namespace-name 的调用,响应 400。

于 2018-06-27T11:07:32.117 回答