
Tech Glossary
Liveness Probe
In Kubernetes, a Liveness Probe is a mechanism used to determine whether an application running inside a container is still functioning correctly. It allows Kubernetes to automatically detect and recover from application failures by restarting containers that are no longer responsive or have entered an unhealthy state. This helps maintain the overall reliability and availability of services within a Kubernetes cluster.
Liveness probes are particularly useful for identifying issues like deadlocks or infinite loops, where an application might appear to be running from the container engine’s perspective but is actually unresponsive or stuck. When a liveness probe fails consistently according to its configuration, Kubernetes assumes the container is broken and restarts it to attempt recovery.
There are three primary types of liveness probes in Kubernetes: HTTP GET, TCP Socket, and Exec. The HTTP GET probe sends requests to a specified endpoint in the application, and if it receives a successful HTTP status code (typically 200–399), the container is considered healthy. The TCP Socket probe attempts to open a TCP connection to a specified port; if the connection is successful, the container is deemed alive. The Exec probe runs a specific command inside the container—if the command exits with a status code of 0, the container is considered healthy.
Each probe can be customized with parameters like initialDelaySeconds (how long to wait before the first check), periodSeconds (how often to run the check), timeoutSeconds (how long to wait for a response), and failureThreshold (how many failures before considering the container unhealthy). These settings ensure that the probe is tailored to the behavior and startup time of your application.
Liveness probes play a critical role in building self-healing systems in Kubernetes. By automatically restarting faulty containers, they help ensure continuous availability and reduce the need for manual intervention during runtime issues.
Learn more about Liveness Probe