Menu

US Region

Grandmetric LLC
Brookfield Place Office
200 Vesey Street
New York, NY 10281
EIN: 98-1615498
Phone: +1 302 691 94 10

info@grandmetric.com

EMEA Region

GRANDMETRIC Sp. z o.o.
ul. Metalowa 5, 60-118 Poznań, Poland
NIP 7792433527
+48 61 271 04 43
info@grandmetric.com

Kubernetes Liveness Probes with examples

Kubernetes Liveness Probes – review

Category: DevOps


02.11.2020
Providing reliable, high-availability applications is combined with the need to automate the control of the application state. Kubernetes provides a set of tools to facilitate this task. This article will focus on the Liveness probe object, I will show the applications of each type – TCP Socket, Command Execution, HTTP Request.

TCP Socket

This kind of establishing a TCP connection to a pod (or pods) on the port specified in the configuration. This solution is especially useful for “non-HTTP” applications, for example Postfix mail server. Liveness probe tries to connect to pod, if no connection fails, pod (or pods) will reboot.

Situation where everything is fine:

 

Example situation where container port mismatch with the port define in Liveness probe configuration (like close port in real situation):

Command Execution

In this case, liveness probe will execute the command inside the container and check the returned status. The container is restarted when a status other than 0 is returned

Situation where everything is fine:

Example with problem:

HTTP Request

This case is very helpful when maintaining WEB applications. Liveness prob recurring polls the endpoint responsible for restoring the health of the application. Returning a status from the 4xx and 5xx family will qualify the pod (pods) for restart.

Situation when health status endpoint return 2xx status code: 

 

Situation when endpoint return status code 4xx or 5xx:

Summary

In this article, I would like to illustrate how individual Liveness probes work. Specific examples to use once with all side options are described in Design & Config.

Author

Wojciech Tokarski

Software Engineer and Kubernetes Certified Professional

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign up to our newsletter!


Grandmetric