Kubernetes Liveness Probe

 Kubernetes Liveness Probe

 

Health Check

One of the most benefits of using Kubernetes it keep our containers running somewhere within the cluster.
But what if one among those containers dies? What if all containers of a pod die?
If app containers crashes due to 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 thanks to check health your application.
Pods are often configured to periodically check an application’s health from the surface and not depend upon the app doing it internally.
You can specify a liveness looked for each container within the 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 an equivalent container being restarted again.

Probe Types

There are three sorts of probes

1.HTTP GET
This type of probe convey request on the container’s IP address, a port and path you specify.
Probe is taken into account failure and container are going to be automatically restarted if
Probe receives error response code
Container app doesn’t respond in the least
2. TCP Socket
TCP socket probe tends to open a TCP connection to the required 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.

1 thought on “Kubernetes Liveness Probe”

Leave a Comment