Can a pod be forcefully marked as "terminating" using liveness probe or any other way

10/30/2019

We have a use case in our application where we need the pod to terminate after it processes a request. The corresponding deployment will take care of spinning up a new pod to maintain the replica count.

I was exploring to use liveness probes, but they only restart the containers and not the pods. Is there any other way to terminate the pod, from service level or deployment level?

-- LPT
kubernetes
kubernetes-pod

1 Answer

10/31/2019

You need to get familiar with Pod lifetime

In general, Pods do not disappear until someone destroys them. This might be a human or a controller. The only exception to this rule is that Pods with a phase of Succeeded or Failed for more than some duration (determined by terminated-pod-gc-threshold in the master) will expire and be automatically destroyed.

In your case consider using Jobs.

Use a Job for Pods that are expected to terminate, for example, batch computations. Jobs are appropriate only for Pods with restartPolicy equal to OnFailure or Never.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow