使用Kubernetes是否有一种方法可以等待吊舱完成其正在进行的任务然后再进行更新? [英] With Kubernetes Is there a way to wait for a pod to finish its ongoing tasks before updating it?

查看:72
本文介绍了使用Kubernetes是否有一种方法可以等待吊舱完成其正在进行的任务然后再进行更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在kubernetes中管理一个应用程序, 我有一个前端(nginx,烧瓶)和一个后端(芹菜) 使用中间件(rabbitmq)将长时间运行的任务发送到后端

I'm managing a application inside kubernetes, I have a front end (nginx, flask) and a backend (celery) Long running tasks are sent to the backend using a middle-ware (rabbitmq)

我的问题是我可以随时接收长时间运行的任务,并且我不希望它干扰我升级应用程序版本的计划.

My issue here is that i can receive long running tasks at anytime, and i don't want it to disturb my plan of upgrading the version of my application.

我正在使用命令kubectl apply -f $MY_FILE部署/更新我的应用程序.但是,如果我在芹菜大棚繁忙时这样做,那么大棚将被终止,而我将丢失任务.

I'm using the command kubectl apply -f $MY_FILE to deploy/update my application. But if i do it when a celery po is busy, the pod will be terminated, and i'll be losing the task.

我尝试使用就绪探针,但吊舱仍被终止. 我的问题是,是否有办法让kube只定位免费"吊舱,并等待忙碌的任务完成?

I tried using the readiness probe, but the pods are still being terminated. My question is, is there a way for kube to target only 'free' pods, and wait for the busy on to finish ?

谢谢

推荐答案

您可以使用preStop挂钩在Pod终止之前完成正在进行的任务.

You can use preStop hooks to complete ongoing task before the pod is terminated.

Kubernetes在终止Container之前立即发送preStop事件.除非Pod的宽限期到期,否则Kubernetes对Container的管理将一直持续到preStop处理程序完成为止.有关更多详细信息,请参见

Kubernetes sends the preStop event immediately before the Container is terminated. Kubernetes’ management of the Container blocks until the preStop handler completes, unless the Pod’s grace period expires.For more details, see Termination of Pods.

查看全文

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