【发布时间】:2019-06-11 02:19:23
【问题描述】:
有没有办法配置 liveness probe 以在 Pod 成功完成后停止运行?
我正在使用活跃度探针来确保批处理作业(预计将在几分钟到几周内完成)响应并正常运行。但是,当 Pod 成功完成时,在 Pod 停止服务 liveness probe(在这种情况下,触摸文件)和成功完成后删除 Pod 之间似乎存在延迟。在此延迟期间,liveness probe 失败的次数足以触发 Kubernetes 重新启动 Pod。
除了增加 liveness probe 的失败阈值或周期,或减少 Pod 的终止宽限期之外,我没有遇到任何可能的缓解措施,也没有针对此问题的可靠解决方案。事实上,我在 Kubernetes 的文档中没有发现任何关于在批处理作业中使用 liveness probe 的内容。
kubectl describe pod <pod> 的事件日志如下。我特别感兴趣的是消息Liveness probe failed: OCI runtime exec failed: exec failed: cannot exec a container that has stopped: unknown。
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Unhealthy 55m kubelet, pascal0 Liveness probe failed: OCI runtime exec failed: exec failed: cannot exec a container that has stopped: unknown
Normal Created 55m (x8 over 21h) kubelet, pascal0 Created container
Normal Pulled 55m (x7 over 18h) kubelet, pascal0 Container image "<image>" already present on machine
Normal Started 55m (x8 over 21h) kubelet, pascal0 Started container
下面包含一些相关的作业配置值。
backoffLimit: 10
restartPolicy: OnFailure
livenessProbe:
exec:
command:
- test
- $(stat -c %Y /tmp/healthy) -gt $(($(date +%s) - 10))
initialDelaySeconds: 30
periodSeconds: 60
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
【问题讨论】:
标签: kubernetes