@Mohammad Ajmal Yazdani , we regret the delay and any inconvenience it might have caused. We tried reproducing this behavior without much success. However, if you are observing this, as you have correctly pointed out, liveness probes is the best shot telling Kubernetes to restart the container if critical functionality is impaired.
The kubelet uses liveness probes to know when to restart a container. For example, liveness probes could catch a deadlock, where an application is running, but unable to make progress. Restarting a container in such a state can help to make the application more available despite bugs.
You can refer to this blog which does a good job of explaining how you can set up your liveness probe health check.
----
Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as convenient to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
----
Hope this helps.
Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.