[英]When cronjobs are set to replace, does Kubernetes wait for the previous job to finish shutting down before starting the new one?
[英]In Kubernetes, how to wait for a pod to finish deleting before starting new one
我有一个部署,我一次只需要一个实例即可。 当优雅地关闭 pod 时,另一个会立即启动——无需等待 pod 完成退出。 如何确保在新 pod 启动之前正常删除的 pod 完全消失?
我尝试过的事情:1. 使用 maxSurge: 0 和 maxUnavailable: 1 滚动更新
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
type: RollingUpdate
结果:优雅删除 pod 时,另一个实例立即启动,所以有两个 pod 同时运行,貌似忽略了 maxSurge 值。
与 1 相同,但使用百分比而不是整数
使用重新创建而不是滚动更新
strategy:
type: Recreate
结果:同1
有没有办法直接在 Kubernetes 中获得所需的行为,或者你必须做一些事情,比如添加一个延迟的初始化容器等?
使用有状态集
StatefulSets are valuable for applications that require one or more of the following.
- Stable, unique network identifiers.
- Stable, persistent storage.
- Ordered, graceful deployment and scaling.
- Ordered, automated rolling updates.
当优雅地删除 pod 时,另一个实例会立即启动
重新创建部署仅在部署升级期间等待旧版本的终止。 除了部署升级,它不能保证一致性。
参考: https://github.com/kubernetes/kubernetes/issues/27362#issuecomment-524664492
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.