如何监视`preStop`命令的执行? [英] How to monitor executing of `preStop` command?

查看:859
本文介绍了如何监视`preStop`命令的执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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 the FailedPreStopHook event. You can see these events by running kubectl describe pod <pod_name>. Here is some example output of events from running this command [...]

这篇关于如何监视`preStop`命令的执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆