Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand Liveness probe

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to understand Liveness detection, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.

Liveness probe

The Liveness probe allows users to customize the conditions that determine whether the container is healthy or not. If the probe fails, Kubernetes restarts the container.

As an example, create the following Pod:

The startup process first creates the file / tmp/healthy,30 and then deletes it. In our setting, if the / tmp/healthy file exists, the container is considered to be in a normal state, but a failure occurs anyway.

The livenessProbe section defines how to perform Liveness probes:

The way to probe is to check the existence of the / tmp/healthy file through the cat command. If the command executes successfully, the return value is zero, and Kubernetes thinks that the Liveness probe is successful; if the command returns a non-zero value, the Liveness probe fails.

InitialDelaySeconds: 10 specifies that the Liveness probe will be executed after the container starts 10. We usually set it according to the preparation time for the application to start. For example, if it takes 30 seconds for an application to start normally, the value of initialDelaySeconds should be greater than 30.

PeriodSeconds: 5 specifies that the Liveness probe is performed every 5 seconds. If Kubernetes fails to perform three Liveness probes in a row, it will kill and restart the container.

Create the Pod liveness below:

As you can see from the configuration file, the / tmp/healthy exists for the first 30 seconds, and the cat command returns a successful detection of 0 kubectl describe pod liveness Lifetime. During this period, the Events section of the log will display a normal log.

After 35 seconds, the log shows that / tmp/healthy no longer exists and the Liveness probe fails. After dozens of seconds, after several failed probes, the container will be restarted.

In addition to Liveness probes, the Kubernetes Health Check mechanism also includes Readiness probes.

The above is how to understand Liveness detection. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report