为什么pod在成功重启几次后由于Livelity探测失败而崩溃

cedebl8k  于 2022-09-19  发布在  Spring
关注(0)|答案(2)|浏览(201)

我有一个简单的spring boot应用程序,带有以下liveness probe:

livenessProbe:
          httpGet:
            path: /health
            port: 56017
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 1
          failureThreshold: 3

在健康端点中,我简单地抛出一个异常,使其返回500。以下是观察多次重启后新pod的统计数据:

PS C:\Users\xxx\yyy\Desktop> k get pods -n xyz  -w

NAME                                         READY   STATUS             RESTARTS   AGE
springapi-577c6f94b9-9r4lm                   1/1     Running            0          15s
springapi-577c6f94b9-9r4lm                   1/1     Running            1          69s
springapi-577c6f94b9-9r4lm                   1/1     Running            2          2m10s
springapi-577c6f94b9-9r4lm                   1/1     Running            3          3m10s
springapi-577c6f94b9-9r4lm                   1/1     Running            4          4m10s
springapi-577c6f94b9-9r4lm                   1/1     Running            5          5m10s
springapi-577c6f94b9-9r4lm                   0/1     CrashLoopBackOff   5          6m8s
springapi-577c6f94b9-9r4lm                   1/1     Running            6          7m33s
springapi-577c6f94b9-9r4lm                   0/1     CrashLoopBackOff   6          8m28s
springapi-577c6f94b9-9r4lm                   1/1     Running            7          11m
springapi-577c6f94b9-9r4lm                   0/1     CrashLoopBackOff   7          12m
springapi-577c6f94b9-9r4lm                   1/1     Running            8          17m
springapi-577c6f94b9-9r4lm                   1/1     Running            9          18m
springapi-577c6f94b9-9r4lm                   0/1     CrashLoopBackOff   9          19m
springapi-577c6f94b9-9r4lm                   1/1     Running            10         24m
springapi-577c6f94b9-9r4lm                   1/1     Running            11         25m
springapi-577c6f94b9-9r4lm                   0/1     CrashLoopBackOff   11         26m

我注意到,前两次重启的速度与预期一样快。那么#3、#4和355相隔1分钟。到目前为止有点道理。之后,我开始看到崩溃回退,两次重启之间的时间间隔达到5分钟。为什么要仓促后退?为什么在几次重启后重启之间的距离如此之大?
我看到了吊舱的日志。没有什么不寻常的。日志输出如下(这些日志在多次重启后):

2021-04-04 00:46:49.172 DEBUG 1 --- Spring boot startup stuff ...
...
2021-04-04 00:47:23.121  INFO 1 --- Spring boot startup stuff ...
2021-04-04 00:47:23.178 ERROR 1 --- exception stack trace
2021-04-04 00:47:33.010 ERROR 1 --- exception stack trace
2021-04-04 00:47:43.005 ERROR 1 --- exception stack trace
2021-04-04 00:47:43.092  INFO 1 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'

当我运行descripe命令时,我看到如下消息

Container springapi failed liveness probe, will be restarted
Liveness probe failed: HTTP probe failed with statuscode: 500
Back-off restarting failed container

顺便说一句,在这5分钟内,吊舱保持在CrashLoopBackOff状态。我已经多次重启了吊舱。我每次都看到同样的行为。

4xrmg8kj

4xrmg8kj1#

我在一篇文章中找到了这种解释:

Failed containers that are restarted by the kubelet are restarted with an exponential back-off delay (10s, 20s, 40s …) capped at five minutes, and is reset after ten minutes of successful execution.

看起来这是预期的行为。

jljoyd4f

jljoyd4f2#

我有同样的问题与POD有关。相同的CrashLoopBackOff错误,关于livenessProbereadinessProbe,事件中有**400**错误。
我错过了在路径中提到的服务应用程序中创建API
(这里的问题是“路径:/health”。)

我创建了一个带有“/health”的API,并再次部署它,它开始按预期工作。
阿图尔

相关问题