kubernetes - progressDeadlineSeconds 未正确超时

标签 kubernetes kubectl

我将 progressDeadlineSeconds 设置为 120 秒

我部署并运行kubectl rollout status deployment mydeployment

部署失败,1 个更新副本中有 0 个可用 - CrashLoopBackOff

但是 kubectl 仍然永远挂起并显示消息:等待部署“mydeployment”推出完成:1 个更新副本中有 0 个可用...

为什么会发生这种情况,progressDeadlineSeconds 应该强制它失败并导致 kubectl rollout status deployment 以非零返回码退出?

最佳答案

你是对的,kubectl rollout status 如果 Deployment 已超过进度截止日期,则返回非零退出代码。 Progress Deadline Seconds :

.spec.progressDeadlineSeconds is an optional field that specifies the number of seconds you want to wait for your Deployment to progress before the system reports back that the Deployment has failed progressing - surfaced as a condition with Type=Progressing, Status=False. and Reason=ProgressDeadlineExceeded in the status of the resource. The Deployment controller will keep retrying the Deployment. This defaults to 600. In the future, once automatic rollback will be implemented, the Deployment controller will roll back a Deployment as soon as it observes such a condition.

If specified, this field needs to be greater than .spec.minReadySeconds.

这将我们带到了 Min Ready Seconds

.spec.minReadySeconds is an optional field that specifies the minimum number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available. This defaults to 0 (the Pod will be considered available as soon as it is ready).

如果没有确切的部署配置,很难判断问题出在哪里,但需要检查的东西很少:

  • 尝试同时设置 progressDeadlineSecondsminReadySeconds,记住后者的值必须较小。

  • progressDeadlineSeconds 在与 Replicas: 1 一起使用时可能不受尊重。检查您的 maxUnavailable 参数以查看它是否允许部署完全不可用。

  • 作为解决方法,您可以为 kubectl rollout status 命令指定超时期限。例如:kubectl rollout status deployment mydeployment --timeout=120s

  • 如果您不想等待发布完成,则可以使用 --watch=false。您将不得不通过运行 kubectl describe deploymentkubectl get deployment 命令手动检查状态,这可能并不理想。

如果有帮助,请告诉我。

关于kubernetes - progressDeadlineSeconds 未正确超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62153399/

相关文章:

git - 从 Kubernetes secret 获取凭据时的 go-git 基本身份验证问题

kubernetes - 在 GCP 中使用 Cloud Shell 访问私有(private) Kubernetes 集群

kubernetes - kubernetes 端口和容器名称中允许使用哪些字符?

kubernetes - 通过 Kustomize 将对象添加到 yaml 中的数组

kubernetes - 在金丝雀部署策略中,将特定用户重定向到具有新版本的 pod

kubernetes - oc get pods - 命令只打印 pod 名称

kubernetes - 如何在 kops 上禁用 --basic-auth-file?库伯内斯

azure - 如何为事件驱动的微服务实现 "debouncing"?

spring-boot - 在Kubernetes Pod中访问Spring Boot Controller端点

java - 用于运行和公开 docker 镜像的 Kubernetes 客户端 API