Readiness detection - 5 minutes a day to play with Docker container technology (144)

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

The user can tell Kubernetes when to restart the container to achieve self-healing through the Liveness detection; the readiness detection tells Kubernetes when the container can be added to the Service load balancing pool to provide external services.

The configuration syntax for Readiness probes is exactly the same as for Liveness probes. Here is an example:

This configuration file just  liveness replaces  the one in the previous example readiness, let's see what the difference is.

readiness The  state of the Pod  READY has undergone the following changes:

  1. When just created, the READY status is unavailable.

  2. After 15 seconds (initialDelaySeconds + periodSeconds), readiness detection is performed for the first time and it returns successfully, which is set  READY to available.

  3. After 30 seconds, it /tmp/healthy is deleted, and after 3 consecutive readiness detections fail, it READY is set as unavailable.

You can  kubectl describe pod readiness also see the log of the readiness detection failure.

The following is a comparison of Liveness detection and Readiness detection:

  1. Liveness detection and readiness detection are two kinds of health check mechanisms. If not specially configured, Kubernetes will adopt the same default behavior for both detections, that is, to determine whether the detection is successful by judging whether the return value of the container startup process is zero.

  2. The configuration methods for the two probes are exactly the same, and the supported configuration parameters are also the same. The difference is the behavior after the probe fails: Liveness probe is to restart the container; Readiness probe is to set the container to be unavailable and not receive requests forwarded by the Service.

  3. Liveness detection and readiness detection are performed independently, and there is no dependency between them, so they can be used alone or at the same time. Use Liveness detection to determine whether the container needs to be restarted to achieve self-healing; use Readiness detection to determine whether the container is ready to provide external services.

After understanding the principles of Liveness detection and Readiness detection, we will discuss how to use Health Check in business scenarios in the next section.

Books:
1. "Play with Docker Container Technology in 5 Minutes a Day"
https://item.jd.com/16936307278.html

2. "Fun with OpenStack for 5 minutes a day"
https://item.jd.com/12086376.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325061652&siteId=291194637