简体   繁体   English

正常关闭明确选择的Pod

[英]Graceful shutdown of explicitly selected pod

I would like to remove a given, exact, selected pod from a set of pods controlled by the same Replication Controller, or the same Replica Set. 我想从同一复制控制器或同一副本集控制的一组容器中删除给定的,精确的选定容器。
The use case is the following: each pod in the set runs a stateful (but in-memory) application. 用例如下:集合中的每个Pod运行一个有状态(但在内存中)的应用程序。 I would like to remove a pod from the set on a graceful way, ie before the removal I would like to be sure, that there are no ongoing application sessions handled by the pod. 我想以一种优美的方式从集合中删除一个pod,即在删除之前,我要确保没有持续的Pod处理应用程序会话。 Let's say I can solve the task of emptying the pod on application level, ie no new sessions are directed to the selected pod, and I can measure the number of ongoing sessions in the pod, so I can decide when to remove the pod. 假设我可以解决在应用程序级别上清空容器的任务,即没有新的会话定向到所选容器,并且我可以测量容器中正在进行的会话数,因此可以决定何时移除容器。 The hard part is to remove this pod so, that RC or RS does not replace the pod with a new one based on the value of "replicas". 困难的部分是删除此容器,以使RC或RS不会根据“副本”的值用新容器替换该容器。
I could not find a solution for this. 我找不到解决方案。 The nearest one would be to isolate the pod from the RC or RS as suggested by http://kubernetes.io/docs/user-guide/replication-controller/#isolating-pods-from-a-replication-controller Though, the RC or RS replaces the isolated pod with a new one, according to the same document. 按照http://kubernetes.io/docs/user-guide/replication-controller/#isolating-pods-from-a-replication-controller的建议,最接近的是将Pod与RC或RS隔离开来。根据同一文档,RC或RS用一个新的隔离吊舱代替。 And I as can understand there is no way to isolate the pod and decrease the value of "replicas" on an atomic way. 我可以理解,没有办法以原子的方式隔离豆荚并降低“副本”的价值。
I have checked the coming PetSet support, but my application does not require eg persistent storage, or persistent pod ID. 我已经检查了即将提供的PetSet支持,但是我的应用程序不需要例如持久性存储或持久性Pod ID。 Such features are not necessary in my case, so my application is not really a pet from this perspective. 就我而言,此类功能不是必需的,因此从这个角度来看,我的应用程序并不是真正的宠儿。
Maybe a new pod state (eg "target for removal" - state name is not important for me) would make it, which could be patched via the API, and which would be considered by RC or RS when the value of "replicas" is decreased? 可能会创建一个新的pod状态(例如,“移除目标”-状态名称对我而言并不重要),可以通过API对其进行修补,并且当“ replicas”的值为减少了?

You can achieve this in three steps: 您可以通过三个步骤来实现:

  1. Add a label to all pods except the one you want to delete. 将标签添加到除要删除的标签之外的所有其他标签上。 Because the labels of the pods still satisfy the selector of the Replica Set, so no new pods will be created. 由于吊舱的标签仍然满足副本集的选择器,因此将不会创建新的吊舱。

  2. Update the Replica Set: adding the new label to the selector and decrease the replicas of the Replica Set atomically. 更新副本集:将新标签添加到选择器中,并自动减少副本集的副本。 The pod you want to deleted won't be selected by the Replica Set because it doesn't have the new label. 副本集不会选择要删除的窗格,因为它没有新标签。

  3. Delete the selected pod. 删除选定的窗格。

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

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