简体   繁体   English

k8s liveness probe失败时发送给容器中运行的进程的信号是什么? 杀死或终止

[英]What is the signal sent to the process running in the container when k8s liveness probe fails? KILL or TERM

I have a use case to gracefully terminate the container where i have a script to kill the process gracefully from within the container by using the command "kill PID".( Which will send the TERM signal ) But I have liveness probe configured as well.我有一个用例可以优雅地终止容器,其中我有一个脚本可以使用命令“kill PID”从容器内优雅地终止进程。(这将发送 TERM 信号)但我也配置了活性探针。 Currently liveness probe is configured to probe at 60 second interval.当前活性探针配置为以 60 秒的间隔进行探测。 So if the liveness probe take place shortly after the graceful termination signal is sent, the overall health of the container might become CRITICAL when the termination is still in progress.因此,如果在发送正常终止信号后不久进行活性探测,则当终止仍在进行中时,容器的整体健康状况可能会变得至关重要。 In this case the liveness probe will fail and container will be terminated immediately.在这种情况下,活性探测将失败,容器将立即终止。

So i wanted to know whether kubelet kills the container with TERM or KILL.所以我想知道 kubelet 是用 TERM 还是 KILL 来杀死容器。

Appreciate your support Thanks in advance感谢您的支持 在此先感谢

In Kubernetes, Liveness Probe checks for the health state of a container.在 Kubernetes 中,Liveness Probe 检查容器的健康状态。

To answer your question on whether it uses SIGKILL or SIGTERM, the answer is both are used but in order.要回答关于它是使用 SIGKILL 还是 SIGTERM 的问题,答案是按顺序使用两者。 So here is what happens under the hood.这就是幕后发生的事情。

  1. Liveness probe check fails活性探针检查失败
  2. Kubernetes stops routing of traffic to the container Kubernetes 停止将流量路由到容器
  3. Kubernetes restarts the container Kubernetes 重启容器
  4. Kubernetes starts routing traffic to the container again Kubernetes 再次开始将流量路由到容器

For container restart, SIGTERM is first sent with waits for a parameterized grace period, and then Kubernetes sends SIGKILL.对于容器重启,首先发送 SIGTERM 并等待参数化的宽限期,然后 Kubernetes 发送 SIGKILL。

A hack around your issue is to use the attribute:解决您的问题的一个技巧是使用该属性:

timeoutSeconds

This specifies how long a request can take to respond before it's considered a failure.这指定了请求在被视为失败之前需要多长时间才能做出响应。 You can add and adjust this parameter if the time taken for your application to come online is predictable.如果您的应用程序上线所需的时间是可预测的,您可以添加和调整此参数。

Also, you can play with readinessProbe before livenessProbe with an adequate delay for the container to come into service after restarting the process.此外,您可以在livenessProbe之前使用readinessProbe ,并有足够的延迟让容器在重新启动进程后投入使用。 Check https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ for more details on which parameters to use.检查https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/以获取有关使用哪些参数的更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM