如何监视`preStop`命令的执行? [英] How to monitor executing of `preStop` command?
问题描述
我正在尝试使用pod的生命周期事件.问题是preStop
中的命令根本不运行.有什么方法可以监视它是否已启动?容器的日志为空.
I'm trying to use pod's lifecycle event. Problem is that command from preStop
doesn't run at all. Is there any way to monitor if it was started? Log of the container is empty.
lifecycle:
preStop:
exec:
command: [ "/bin/sh", "-c", "/clean.sh" ]
推荐答案
来自 https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#debugging-hook-handlers
Hook处理程序的日志未在Pod事件中公开.如果处理程序由于某种原因失败,它将广播一个事件. [...]对于
PreStop
,这是FailedPreStopHook
事件.您可以通过运行kubectl describe pod <pod_name>
查看这些事件.这是运行此命令[...]
The logs for a Hook handler are not exposed in Pod events. If a handler fails for some reason, it broadcasts an event. [...] For
PreStop
, this is theFailedPreStopHook
event. You can see these events by runningkubectl describe pod <pod_name>
. Here is some example output of events from running this command [...]
这篇关于如何监视`preStop`命令的执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!