我已经在openshift的Spring Boot上部署了我的服务。 spring boot服务初始化良好,我们看到以下日志是正确的。
2020-05-06 19:32:33.930 INFO 1 --- [ main] c.a.r.l.MyApplication : Started MyApplication in 44.227 seconds (JVM running for 67.578)
2020-05-06 19:32:38.706 INFO 1 --- [nio-8198-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-06 19:32:38.709 INFO 1 --- [nio-8198-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-05-06 19:32:38.802 INFO 1 --- [nio-8198-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 93 ms
但是容器准备就绪状态显示为0 / 1,5分钟后我看到此警告,并且容器重新启动。
The container has been running for more than five minutes and has not passed its readiness check
我知道
Readiness probe failed: HTTP probe failed with statuscode: 404
可能有什么问题?
Readiness probe failed: HTTP probe failed with statuscode: 404
这表示您为readinessProbe
指定的URL不存在(HTTP 404
)。因此,请检查readinessProbe
的定义方式(调用哪个URI),并确保存在有效的响应。
对于Spring Boot,有一个用于运行状况端点的执行器,请参见以下文档:https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html
这里是一个例子:
[..]
spec:
containers:
- args:
image: k8s.gcr.io/readiness
readinessProbe:
httpGet:
path: /healthz
在上面的示例中,确保/healthz
端点存在。
您可以在OpenShift documentation中找到有关如何配置就绪探针的更多信息。