How can a pod have status ready and terminating?

4/23/2019

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

-- arshbot
kubernetes

2 Answers

4/23/2019

When pods are in terminating state, they could still be functioning. The pod could be delayed in termination due to many reasons (eg. could be that you have a PVC attached, other pods are being terminated at the same time, etc). You could test this by running the following on a pod with a PVC attached or another reason to be terminated with a delay:

$ 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

Sometimes this happens because the pod is still in the terminating period and is functioning normally, so it will be treated as an existing pod that gets configured (neglecting the fact that you usually can't configure pods like this, but you get the point).

-- cookiedough
Source: StackOverflow

4/23/2019

The ready column says how many containers are up.

The status terminating means no more traffic is being sent to that pod by the controllers. From kubernetes' docs:

When a user requests deletion of a pod, the system records the intended grace period before the pod is allowed to be forcefully killed, and a TERM signal is sent to the main process in each container. Once the grace period has expired, the KILL signal is sent to those processes, and the pod is then deleted from the API server.

That's the state it is. The containers are up, finishing processing whatever work it had already and a TERM signal was sent.

-- nrxr
Source: StackOverflow