gpt4 book ai didi

kubernetes - 保持kubernetes pod运行,直到最后一个用户断开连接

转载 作者:行者123 更新时间:2023-12-02 11:44:47 25 4
gpt4 key购买 nike

我在kubernetes上运行了一个node.js容器,该容器处理websocket连接,这些连接通常保持打开状态,直到用户退出为止。现在,当我进行滚动更新或按比例缩小部署时,是否有办法阻止Pod被杀死,直到最后一个用户断开连接为止?

最佳答案

目前,Kubernetes不支持优雅的连接关闭。
terminationGracePeriodSeconds仅在Pod终止之前定义计时器。它不会处理Pod连接。

处理滚动更新的唯一方法是调整您的应用程序,使其能够透明地将客户端切换到其他Pod。

您可能还想看看Disruption Budget。在某些情况下,进行更可靠的设置可能会有所帮助。

A PDB specifies the number of replicas that an application can tolerate having, relative to how many it is intended to have. For example, a Deployment which has a .spec.replicas: 5 is supposed to have 5 pods at any given time. If its PDB allows for there to be 4 at a time, then the Eviction API will allow voluntary disruption of one, but not two pods, at a time.

PDBs cannot prevent involuntary disruptions from occurring, but they do count against the budget.

Pods which are deleted or unavailable due to a rolling upgrade to an application do count against the disruption budget, but controllers (like deployment and stateful-set) are not limited by PDBs when doing rolling upgrades – the handling of failures during application updates is configured in the controller spec. (Learn about updating a deployment.)

When a pod is evicted using the eviction API, it is gracefully terminated (see terminationGracePeriodSeconds in PodSpec.)

关于kubernetes - 保持kubernetes pod运行,直到最后一个用户断开连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51060941/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com