Score:0

Why Kubernetes restarts some pod and doesn't restart another?

au flag

Would anyone be so kind as to point me to the piece of documentation which explains the following phenomenon?

When we run kubectl run --rm --stdin --tty --image hello-world hello-pod , it's being restarted by Kubernetes automatically. Why does Kubernetes forget to delete it?

At the same time, if we run kubectl run --rm --stdin --tty --image busybox busy-pod, it's being automatically deleted (which seems to be quite legit).

Any suggestion is appreciated. Thank you.

Score:2
cn flag

The reason why the first pod is being restarted is that there's probably an error there and kubernetes keeps restarting it "in the hope" that it will solve the issue eventually. When you run that, you get a 'CrashLoopBack', but then Kubernetes does delete it eventually, but only after a while:

kubectl run --rm --stdin --tty --image hello-world hello-pod
pod "hello-pod" deleted
error: timed out waiting for the condition

Kubernetes deletes the second pod also the moment you exit the tty (ctrl + D). And the reason for that is that the process ends and you've added the '--rm' option which does exactly that - it automatically deletes pods when the process terminates, which in this case means just exiting the terminal/bash/shell etc.

au flag
Thank you. Of course, I suggested that the application in the container returns an error code, but it doesn't: `docker run hello-world >/dev/null; echo "${?}"` returns `0`. :-(
cn flag
My answer is partially wrong though, I realise now. The second time I've created the pod, kubernetes keeps restarting it. But the reason for that is, indeed, an error (that's why you can see `CrashLoopBackOff` when you list the pods). The description is not necessarily more useful: "Back-off restarting failed container". But something does return a non-zero code, but I admit I'm not sure what. That's the reason though why kubernetes keeps restarting it instead of deleting it. But that's not consistent, sometimes it does delete it at some point, because the process exits with 0. Interesting :)
au flag
Yes, that's exactly what I can't get. Why Kubernetes considers it as failed?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.