Is there a way to limit the number of restarts of pod?

I have implemented liveness probe in my kubernetes deployment file. as of now it attempts restart infinite number of times. Is there a way to limit this number of restart attempts?

Not yet unfortunately as far as I am aware of. There was an attempt to build the feature but it didn’t get completed by the looks of it Add support for max local retries for RestartOnFailure policy by hex108 · Pull Request #79334 · kubernetes/kubernetes · GitHub.

What behavior are you trying to achieve?

yeah i had a look at that … hopefully they add that feature…

i added liveness probe … and I wanted it to stop restarting my container after ‘x’ number of attempts rather than restarting infinitely