0

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?

Steve
  • 145
  • 1
  • 8

1 Answers1

1

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.

leodotcloud
  • 1,830
  • 14
  • 15
  • That sounds right. This image is extended from the WordPress FPM image and the dockerfile ends with `CMD ["php-fpm"]` . How do I get the application to stop on error? Is there a change I make in php.ini? – Steve May 19 '18 at 15:31
  • @Steve I don't know the internal workings of that application, so can't comment on the details. Another thing I could think of is configuring a healthcheck on the container. If there is a particular endpoint which might not work or show a different HTTP code when an error happens, it could be used in the config. See here: https://kubernetes.io/docs/user-guide/walkthrough/k8s201/#application-health-checking – leodotcloud May 21 '18 at 18:46