How can a pod have status ready and terminating?

时间:2019-04-23 15:13:18

标签: kubernetes

Curiously, I saw that a pod I had had both ready 1/1 status and status terminating when I ran kubectl get pods. Are these states not mutually exclusive? Why or why not?

For context, this was noticed immediately after I had killed skaffold so these pods were in the middle of shutting down.

enter image description here

3 个答案:

答案 0 :(得分:4)

吊舱处于终止状态时,它们可能仍在运行。由于多种原因(例如,可能是您已连接PVC,其他吊舱同时被终止,等等),吊舱可能会延迟终止。您可以通过在附有PVC或其他原因导致延迟终止的Pod上运行以下命令来进行测试:

$ kubectl delete pod mypod-xxxxx-xxxxxx
pod mypod-xxxxx-xxxxxx deleted

$ kubectl delete pod mypod-xxxxx-xxxxxx
pod mypod-xxxxx-xxxxxx deleted

$ kubectl apply mypod.yaml
pod mypod-xxxxx-xxxxxx configured

有时会发生这种情况,因为Pod仍处于终止阶段并且运行正常,因此将其视为已配置的现有Pod(忽略了您通常无法像这样配置Pod的事实,但是您得到了重点)。

答案 1 :(得分:3)

“准备就绪”列显示了多少个容器。

状态终止表示控制器不再将任何流量发送到该Pod。来自Automapper

  

当用户请求删除Pod时,系统会记录   允许强制启用Pod之前的预期宽限期   被杀死,并且TERM信号被发送到每个   容器。宽限期结束后,将发送KILL信号   这些进程,然后将pod从API服务器中删除。

那是它的状态。容器已经装好,完成了对已经完成的工作的处理,并发送了TERM信号。

答案 2 :(得分:1)

我想更新@nrxr 答案:

<块引用>

状态终止意味着控制器不再向该 Pod 发送流量。

这就是我们想要的,但实际上并不总是这样。 Pod 可能会完全终止,而流量仍会转发给它。
有关详细信息,请阅读此博客:https://learnk8s.io/graceful-shutdown

相关问题