How long do Kubernetes Pods persist?

10/25/2016

How long does a pod persist without a replication controller?

I have run some pods that have a very simple purpose, they execute and then terminate. Other pods like a database server pod persists for quite a longer time. However after a day or so, the pod would terminate. I know docker containers exit once their process has finished running, but why would my database pods continue running for a while and then randomly exit.

What controls the termination of a pod?

-- Shuaib
kubernetes

1 Answer

10/26/2016

The easiest way for you to find a definitive answer to that question would be to kubectl describe pod <podName>, or kubectl get events. Any pod termination would have an associated event that you can use to diagnose the reason.

Pods may die due to several reasons, ranging from errors within the container, to a node going down for maintenance. You can usually set the appropriate RestartPolicy, which will restart the pod if it fails (except in case of node failure). If you have multiple nods and would like the pod to be restarted on a different node, you should use a higher level controller like a ReplicaSet or Deployment.

For pods expected to terminate, a job is better suited.

-- Anirudh Ramanathan
Source: StackOverflow