我将 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 withType=Progressing
,Status=False
. andReason=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).
如果没有确切的部署配置,很难判断问题出在哪里,但需要检查的东西很少:
尝试同时设置
progressDeadlineSeconds
和minReadySeconds
,记住后者的值必须较小。progressDeadlineSeconds
在与Replicas: 1
一起使用时可能不受尊重。检查您的maxUnavailable
参数以查看它是否允许部署完全不可用。作为解决方法,您可以为
kubectl rollout status
命令指定超时期限。例如:kubectl rollout status deployment mydeployment --timeout=120s
如果您不想等待发布完成,则可以使用
--watch=false
。您将不得不通过运行kubectl describe deployment
和kubectl get deployment
命令手动检查状态,这可能并不理想。
如果有帮助,请告诉我。
关于kubernetes - progressDeadlineSeconds 未正确超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62153399/