Kubernetes CrashLoopBackOff 默认时序

Kubernetes CrashLoopBackOff default timing

Kubernetes CrashLoopBackOff 的默认设置是什么?

说,我有一个豆荚:

kubectl run mynginx --image nginx -- echo hello

然后我检查它的状态:

kubectl get pods -w
NAME      READY   STATUS    RESTARTS   AGE
mynginx   0/1     Pending   0          0s
mynginx   0/1     Pending   0          0s
mynginx   0/1     ContainerCreating   0          0s
mynginx   0/1     Completed           0          2s
mynginx   0/1     Completed           1          4s
mynginx   0/1     CrashLoopBackOff    1          5s
mynginx   0/1     Completed           2          20s
mynginx   0/1     CrashLoopBackOff    2          33s
mynginx   0/1     Completed           3          47s
mynginx   0/1     CrashLoopBackOff    3          59s
mynginx   0/1     Completed           4          97s
mynginx   0/1     CrashLoopBackOff    4          109s

这是“预期的”。 Kubernetes 启动一个 pod,它退出“太快”,Kubernetes 再次调度它,然后 Kubernetes 将状态设置为 CrashLoopBackOff.

现在,如果我以稍微不同的方式启动 pod:

kubectl run mynginx3 --image nginx -- /bin/bash -c "sleep 10; echo hello"

我得到以下内容

kubectl get pods -w
NAME       READY   STATUS    RESTARTS   AGE
mynginx3   0/1     Pending   0          0s
mynginx3   0/1     Pending   0          0s
mynginx3   0/1     ContainerCreating   0          0s
mynginx3   1/1     Running             0          2s
mynginx3   0/1     Completed           0          12s
mynginx3   1/1     Running             1          14s
mynginx3   0/1     Completed           1          24s
mynginx3   0/1     CrashLoopBackOff    1          36s
mynginx3   1/1     Running             2          38s
mynginx3   0/1     Completed           2          48s
mynginx3   0/1     CrashLoopBackOff    2          62s
mynginx3   1/1     Running             3          75s
mynginx3   0/1     Completed           3          85s
mynginx3   0/1     CrashLoopBackOff    3          96s
mynginx3   1/1     Running             4          2m14s
mynginx3   0/1     Completed           4          2m24s
mynginx3   0/1     CrashLoopBackOff    4          2m38s

这也在意料之中。

但是假设我将 sleep 设置为 24 小时,在最初两个 pod 退出后以及在每个下一个 pod 退出后我仍然会得到相同的 CrashLoopBackOff 吗?

基于these docs

The restartPolicy applies to all containers in the Pod. restartPolicy only refers to restarts of the containers by the kubelet on the same node. After containers in a Pod exit, the kubelet restarts them with an exponential back-off delay (10s, 20s, 40s, …), that is capped at five minutes. Once a container has executed for 10 minutes without any problems, the kubelet resets the restart backoff timer for that container.

我认为这意味着任何在退出前执行时间超过 10 分钟的内容都不会触发 CrashLoopBackOff 状态。