Readiness probe
Readiness probe determines whether a container is ready to receive the traffic or not. Internally, Kubernetes checks the readiness probe periodically and validate the response. By any chance if the readiness probe fails, then Kubernetes remove this pod from serving the traffic.
Following properties can be configured for a readiness probe.
Property |
Description |
initialDelaySeconds |
Specifies number of seconds to wait before running the readiness probe for the first time. This helps in giving container some time to start up. |
periodSeconds |
Specifies the number of seconds between readiness probe checks. |
timeoutSeconds |
Specifies the number of seconds to wait for a readiness probe to respond before marking the pod as unhealthy. |
failure Threshold |
Specifies the number of consecutive readiness probe failures that must occur before the pod state is set to unhealthy. |
Example
readinessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
Above snippet used to perform HTTP GET requests to the "/healthz" path on port 80 of the container to check the health of readiness probe. This check starts 5 seconds after the container starts and repeating every 10 seconds. The probe will time out after 1 second of waiting for a response, and if it fails 3 times in a row, the container will be considered not ready for incoming network traffic.
What happen when a readiness probe does not respond?
The pod longer able to serve traffic. Once the readiness probe is able to respond successfully, then Kubernetes will mark the pod as Ready and it will start receiving traffic again.
Liveness probe
Liveness probe helps Kubernetes to check whether a container is still alive or not. Kubernetes will periodically run the liveness probe, and if the probe fails, Kubernetes will restart the container. Liveness probes are used to detect unhealthy containers.
Property |
Description |
initialDelaySeconds |
Specifies number of seconds to wait before running the liveness probe for the first time. This helps in giving container some time to start up. |
periodSeconds |
Specifies the number of seconds between liveness probe checks. |
timeoutSeconds |
Specifies the number of seconds to wait for a liveness probe to respond before marking the pod as unhealthy. |
failure Threshold |
Specifies the number of consecutive liveness probe failures that must occur before the pod state is set to unhealthy. |
Example
livenessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 10
periodSeconds: 15
timeoutSeconds: 1
failureThreshold: 3
In the above snippet, liveness probe is configured to perform an HTTP GET request to the "/healthz" path on port 80 of the container. The initialDelaySeconds parameter dictates that the first liveness probe check will start 10 seconds after the container is launched. Subsequent checks will occur at 15-second intervals (periodSeconds). The probe will consider itself failed if it doesn't receive a response within 1 second (timeoutSeconds) and will tolerate up to 3 consecutive failures (failureThreshold) before marking the container as unhealthy, potentially triggering actions like restarting the container to maintain the overall system's reliability.
What happen when a liveness probe does not respond?
Kubernetes will restart the container.
No comments:
Post a Comment