I had an incident on one of my pods where code got corrupted. One pod would output a php error message instead of the correct page content ("unexpected end of file"), but since there were numerous correct pods most of the time a visitor would get the normal page. Since there was output, my current health check succeeded and the container was allowed to run with the error for many hours before the problem was noticed.
How do I configure kubernetes to recognize this problem and restart the container?
In your application code, if you exit the application when you hit an error condition, kubernetes will detect the stopped/exited pod and recreate a new one.