Kubernetes 101 : Checking the "Health" of pods - liveness probes -
kubernetes uses a process to check the "health" of the application running inside a container. If the application stops, the kubernetes kubelet takes care of restating it.
Health checks are valuable for testing if an application is still running, but what if the application is still running but is hanging for some reason. The health checks would still report the application as "healthy".
To check that our application is still "alive" and functioning as it should and not just hanging, we use "liveness" checks.
Liveness health checks:
Liveness health checks run a task related to the application, for example, we could run the command "ls" inside a "debian" container to check if "debian" is functioning as it should, and not running in a "hanging" state ( see below example ).
The kubelet uses the liveness check to make a decision about whether or not to restart a pod.
Below a Yaml file of a pod with an exec liveness check on a "debian" container:
Other types of probes:
There are other types of liveness probes:
*The HTTP probe: which uses an HTTP GET request to check if the application is running properly
*The TCP probe: which opens a connection to a certain port specific to an application, to test if it is responding.
Comments