编程技术网

关注微信公众号,定时推送前沿、专业、深度的编程技术资料。

 找回密码
 立即注册

QQ登录

只需一步,快速开始

极客时间

当kubernetes cron作业吊舱被“替换"终止时,停机的状态如何?并发策略?:What does shutdown look like for a kubernetes cron job pod when it's being terminated by "replace" concurrency policy?

vlyalcin Kubernetes 2022-5-10 15:07 13人围观

腾讯云服务器
当kubernetes cron作业吊舱被“替换"终止时,停机的状态如何?并发策略?的处理方法

我在kubernetes官方文档中找不到关于此的任何内容.替换长期运行的cron作业的实际低层流程是什么?我想了解这一点,以便我的应用程序可以正确处理它.

I couldn't find anything in the official kubernetes docs about this. What's the actual low-level process for replacing a long-running cron job? I'd like to understand this so my application can handle it properly.

  • 是干净的 SIGHUP / SIGTERM 信号被发送到正在运行的应用程序吗?
  • 在发送该信号后是否有一个等待期,因此应用有时间清理/关闭,然后有可能被杀死?如果是这样,那超时时间是几秒钟?还是永远等待?
  • Is it a clean SIGHUP/SIGTERM signal that gets sent to the app that's running?
  • Is there a waiting period after that signal gets sent, so the app has time to cleanup/shutdown before it potentially gets killed? If so, what's that timeout in seconds? Or does it wait forever?

作为参考,这是文档中的 Replace 策略说明:

For reference, here's the Replace policy explanation in the docs:

https://kubernetes.io/docs/任务/作业/带有cron作业的自动化任务/

并发策略

  • 替换:如果是时候开始新的任务运行并且之前的任务尚未完成,则cron任务会用新的任务运行替换当前正在运行的任务运行

问题解答

CronJob的下面只有另一个Pod.

A CronJob has just another Pod underneath.

当并发策略为替换"的Cronjob仍处于活动状态时,

When a Cronjob with a concurrency policy of "Replace" is still active, the Job will be deleted, which also deletes the Pod.

当Pod被删除时,在宽限期(默认为30秒)后,将向Linux容器发送 SIGTERM ,然后发送 SIGKILL .

When a Pod is deleted the Linux container/s will be sent a SIGTERM and then a SIGKILL after a grace period, defaulted to 30 seconds. The terminationGracePeriodSeconds property in a PodSpec can be set to override that default.

由于

Due to the flag added to the DeleteJob call, it sounds like this delete is only deleting values from the kube key/value store. Which would mean the new Job/Pod could be created while the current Job/Pod is still terminating. You could confirm with a Job that doesn't respect a SIGTERM and has a terminationGracePeriodSeconds set to a few times your clusters scheduling speed.

这篇关于当kubernetes cron作业吊舱被“替换"终止时,停机的状态如何?并发策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程技术网(www.editcode.net)!

腾讯云服务器 阿里云服务器
关注微信
^