简体   繁体   English

如何在终止Pod的同时确定kubernetes的宽限期?

[英]How to determine the graceful period of kubernetes while terminating a pod?

we'd like to scale in some of the running instances on which many kubernetes pods are running. 我们想在运行许多kubernetes pod的一些正在运行的实例中进行扩展。 So, we are going to gracefully stop the pods by using graceful period according to the official document termination-of-pods . 因此,根据正式文档pod-of-pods ,我们将使用graceful period来优雅地停止Pod I have read many blog posts and official document, they all tells how to gracefully terminate pod with graceful period . 我看了很多博客和官方文件,都将告诉您如何正常终止荚graceful period But they do not say how to determine how long the graceful period would be better. 但是他们没有说如何确定graceful period会更好。

Let's say, for example, a container in a pod may serves for thousands of requests in a time period and it will spend more than 30s to complete all request. 比方说,例如,一个容器中的一个容器可能在一个时间段内处理数千个请求,并且要花费30多秒才能完成所有请求。 I think in this case it would be a bad idea to set graceful period to 30s, because some of the request would be lost. 我认为,在这种情况下,这将是一个坏主意,设置graceful period到30年代,因为一些请求会丢失。 However, when the user load is down and the same container in the same pod serves for only dozens of request in other time period and it only spend 5s to complete all, in this case 30s for graceful period would be too long. 但是,当用户负载下降并且同一容器中的同一容器在其他时间段内仅可满足数十个请求,并且仅花费5s来完成所有请求时,在这种情况下,30s的graceful period将太长。

That's my consideration. 那是我的考虑。 So, my question is as follows. 因此,我的问题如下。 1. Is there any best practice to determine how long the graceful period is better? 1.是否有最佳实践来确定graceful period更好? 2. Is there any approach to check if the processing request is completed in a container and then gracefully terminate pod? 2.有什么方法可以检查处理请求是否在容器中完成,然后正常终止pod? 3. Can I extend the initial graceful period after sending the termination command to a pod? 3.我可以延长最初的graceful period发出终止命令吊舱后?

Thanks in advance. 提前致谢。

The best way to determine the ideal graceful period is by observability. 确定理想宽限期的最佳方法是通过可观察性。 Put your service under a realistic production load and measure. 将您的服务置于切实可行的生产负载和衡量标准之下。 This is highly project specific! 这是高度针对项目的!

If the process with PID 1 exits before the graceful period your container will be marked as Terminated before the end of the graceful period, so it's worth setting a value slightly higher than what you would expect under normal circumstances. 如果PID 1的过程在宽限期之前退出,则您的容器将在宽限期结束之前标记为已终止,因此值得设置一个比正常情况下期望值稍高的值。

You might be interested in letting your containers write arbitrary information when they terminate. 您可能有兴趣让您的容器在终止时写入任意信息。 Kubernetes has a feature called Termination messages you might want to look into. Kubernetes具有一项称为终止消息的功能,您可能需要调查一下。

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

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