Is it possible to auto restart a Kubernetes/Openshift pod only if the first start was successful

1/25/2022

I wonder if it is possible to use container restart policy "always" or "onFailure" only if the pod has min. one clean start?

Something like this:

first start -> failed -> never start again

first start -> ok -> "some error" while running -> restart

thanks and best regards.

-- zie-pao
kubernetes
openshift

1 Answer

1/25/2022

This is not possible with Kubernetes/OpenShift built-in controllers. If you need custom behavior you could create a custom resource and a corresponding controller (operator). For more information consider Custom Resources and "Extend the Kubernetes API with CustomResourceDefinitions" in the Kubernetes docs.

-- derkoe
Source: StackOverflow