当 Kubernete Pod 终止并且新的正在运行的 Pod 取代他时,如何防止下一步在 GitHub 操作中运行

发布于 2025-01-16 02:46:39 字数 473 浏览 4 评论 0原文

更新 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.

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事↓在人 2025-01-23 02:46:39

在部署中使用.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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文