Kubernetes Liveness Probe
One of benefits of using Kubernetes it keep our containers running somewhere cluster.
But what if those containers dies? What if all containers of a pod die?
If app containers crashes bug in your app, Kubernetes will restart your app container automatically.
But what would say about those situations when your app stops responding because it falls into an infinite loop or a deadlock?
Kubernetes provide us check health your application.
Pods configured to periodically check an application’s health from and not the app doing it internally.
You can specify a liveness each container pod’s specification.
Kubernetes would periodically execute the probe and restart the container if the probe fails.
IMPORTANT POINT: “Container is restarted” means old one is killed and completely new container is created———it’s not container being restarted again.
This type of probe convey request on the container’s IP address, a port and path you specify.
Probe failure and container automatically restarted if
Probe receives error response code
Container app doesn’t respond
2. TCP Socket
TCP socket probe tends to open a TCP connection to port of the container.
If the connection is maintained successfully, the probe is successful.
Otherwise, the container is restarted.
3. EXEC Probe
An Exec probe do some commands you provide inside the container and checks the command’s exit status code.
If the status code is declared 0, the probe is successful.
All other codes are considered failure.