问题描述
在kubernetes官方文档中,我正在阅读此页面(关于container probes
以及为什么我们应该使用startup-probe
)
何时应-you-use-a-startup探针,它们表示如下:
In kubernetes official docs, I was reading this page (about the container probes
and why we should use startup-probe
)
when-should-you-use-a-startup probe, they stated like:
我了解了为什么需要使用startup probe
的全部内容(据我了解,为什么需要使用startup probe
的原因是:启动探针对于具有需要很长时间才能进入的容器的Pod很有用我们知道,如果提供了启动探针,则所有其他探针都将被禁用,直到成功为止,因此,如果容器需要更长的时间才能启动,那么我们将使用startup probe
,以便在容器启动之前,其余两个探针仍然保留禁用).
I understood the whole things that why we need to use startup probe
(what i understood that why we need to use startup probe
is that: Startup probes are useful for Pods that have containers that take a long time to come into service. As we know, all other probes are disabled if a startup probe is provided, until it succeeds. So if the container takes longer time to start up then we will use startup probe
so that until the container start the other two probes remain disabled).
但是在这里我没有得到deadlock
的情况,deadlock
发生在哪里以及为什么发生?谁能解释他们所谈论的deadlock
情景?通过使用startup probe
我们可以防止哪个deadlock
?
But here I did not get the scenario of deadlock
, where and why the deadlock
is happening? can anyone explain the scenario of the deadlock
that they are talking about? which deadlock
are we preventing by using startup probe
?
推荐答案
startup probe
设计为在容器启动后只能执行一次.
The startup probe
is designed to be performed only once after container start.
Readiness probe
和liveness Probe
不仅是在启动时执行的.
Readiness probe
and liveness Probe
are performed not only the startup.
就绪探测器可以由负载均衡器用来确定何时可以发送流量.
Readiness probe may be used by load balancer to determine when it can send traffic.
使用startup probe
的示例原因是:
您的应用程序启动了很长时间.您可以增加readiness probe
和liveness probe
的delays
,但您不知道容器何时准备就绪,因为在delay
时间内未执行这些探测.
Your application is starting for a long time. You can increase delays
for readiness probe
and liveness probe
but you do not know when your container is ready because those probes are not performed for delay
time.
因此startup probe
通常与readines
和liveness
探针一起使用.它会一直执行到容器准备好为止(直到startup probe
返回Success
状态),因此您不再需要延迟.
So startup probe
is used commonly with readines
and liveness
probes. It is performed until your container is ready(till your startup probe
returns the Success
status), so you do not need delays anymore.
假设您的应用程序启动了1-3分钟(这可能取决于外部API,资源,网络速度慢等).您可以将delays
设置为190秒,但是如果您的容器在60秒后准备就绪,则可以浪费至少2分钟.为了解决该问题,设计了startup probe
.
Let's say your application is starting for 1-3 minutes(it may depend on external API, resources, slow network etc.). You can put delays
to 190 seconds, but you can waste at least 2 minutes if your container is ready after 60 seconds. To solve that issue startup probe
was designed.
有时,您必须处理可能在首次初始化时需要额外启动时间的旧版应用程序.在这种情况下,在不影响对激发此类探测器的死锁的快速响应的情况下,设置活动性探测器参数可能很棘手.诀窍是使用相同的命令HTTP或TCP检查来设置启动探针,并使用failThreshold * periodSecond足够长的时间来覆盖更坏的启动时间.
Sometimes, you have to deal with legacy applications that might require an additional startup time on their first initialization. In such cases, it can be tricky to set up liveness probe parameters without compromising the fast response to deadlocks that motivated such a probe. The trick is to set up a startup probe with the same command, HTTP or TCP check, with a failureThreshold * periodSeconds long enough to cover the worse case startup time.
当您的容器尚未准备好但liveness probe
正在执行并且超过了failure treshold
时,就会出现死锁,这是因为延迟时间太短.在这种情况下,您的容器会不断重启.为了防止这种情况,您应该使用startup probe
并将阈值设置得足够高.
The deadlock is situation, when your container is not ready but liveness probe
is performing and it exceed failure treshold
, because of too short delay time. In this situation your container keeps restarting. To prevent that you should use startup probe
and put your threshold high enough.
这篇关于无法理解“何时应该使用kubernetes的启动探针"中的死锁情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!