当 Kubernete Pod 终止并且新的正在运行的 Pod 取代他时,如何防止下一步在 GitHub 操作中运行
更新 Kubernetes 部署后,需要一段时间来终止旧的 pod 并使用不同的引用名称重新创建一个新的 pod,我想知道是否有任何方法可以阻止下一步在终止 pod 之前在 GitHub 操作中运行已删除。
在一小段时间内,我们有两个状态不同的 Pod 引用同一部署,如果您尝试在下一个 GitHub 操作步骤中运行任何命令,它们会发送错误。
我在上一步中创建了 30 秒的延迟,以便有更多时间删除终止 pod,但我正在寻找为了更干净的方式来做到这一点,
例如“这是我不想在 GitHub 操作中执行的操作”
- 名称:睡眠 30 秒
run:sleep 30s
shell:bash
谢谢你的帮助...
After a Kubernetes deployment has been updated takes a moment to terminate the old pod and recreate a new one with a different ref-name, I wonder if there is any way to prevent the next step from running in GitHub actions before this terminating pod is being removed.
For a small window of time, we have two pods with different statuses referencing the same deployment which send an error if you try to run any command in your next GitHub action step.
I created a 30s delay in the previous step to give more time to remove the terminating pod but I am looking for a cleaner way to do it
e.g. "this is what I don't want to do in my GitHub action"
- name: Sleep for 30 seconds
run: sleep 30s
shell: bash
Thanks for you help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在部署中使用
.spec.strategy.type: Recreate
。这将强制在创建新 pod 之前终止之前的 pod。这里是官方文档: https://kubernetes.io/docs/概念/工作负载/控制器/部署/#strategy
Use
.spec.strategy.type: Recreate
in the Deployment. This will force the previous pods to be terminated before creating new pod.Here, is the official documentation: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy