Basic Docker Behavior
When you run an application in Docker, any crash stops the container until you restart it manually:nginx process crashes:
Kubernetes Automatic Restarts
Kubernetes continuously monitors container exit codes and restarts crashed containers automatically:Without a liveness probe, Kubernetes cannot detect hung or unresponsive applications that have not exited.
Introducing Liveness Probes
A liveness probe defines how Kubernetes determines container health. You choose one of three probe types:
When a container fails its liveness probe, Kubernetes restarts it automatically.
HTTP Liveness Probe Example
initialDelaySeconds: 15
Waits 15 seconds before the first health check.periodSeconds: 10
Probes every 10 seconds.failureThreshold: 3
Restarts the container after three consecutive failures.