Liveness, Readiness, and Startup Probes

Liveness, Readiness, and Startup Probes

·

2 min read

Applications can become inconsistent for a variety of reasons such as temporary connection loss, configuration errors etc.

You can use probes to keep an eye on your applications. Probes let you know about things like the applications status, resources it's using, and any other errors.

Definition:

A probe is a periodic check that monitors the health of the application. You can configure probes either using kubectl command line or YAML deployment template.

Three Types of probes includes:

  • Startup Probe

  • Liveness Probe

  • Readiness Probe

Let us discuss each probe in detail.

1. Startup Probe

A startup probe verifies whether the application within the container is started. Startup probes runs before any other probe and disables any other probes till this probe is completed successfully.

This type of probe is only executed at startup, unlike readiness probes, which are run periodically.

startupProbe:
    httpGet:
        path: /healthz
        port: 8080
    failureThreshold: 30
    periodSeconds: 10

2. Liveness Probe

Liveness probes determine whether or not an application running in a container is in a healthy state. If the liveness probe detects an unhealthy state, then Kubernetes kills the container and tries to redeploy it.

They can help ensure that your application remains available by automatically restarting failed containers.

livenessProbe:
    httpGet:
        path: /healthz
        port: 8080
    initialDelaySeconds: 15
    periodSeconds: 20

3. Readiness Probe

Readiness probes determine whether or not a container is ready to serve requests. If the readiness probe returns a failed state, then Kubernetes removes the IP address for the container from the endpoints of all Services.

Kubernetes relies on the readiness probes during rolling updates, it keeps the old container up and running until the new service declares that it is ready to take traffic.

readinessProbe:
    httpGet:
        path: /ready
        port: 8080
    initialDelaySeconds: 5
    periodSeconds: 10

All three types of probes have common settings to configure.

  • initialDelaySeconds: How many seconds to wait after the container has started.

  • periodSeconds: Wait time between probe executions.

  • timeoutSeconds: Timeout of the probe.

  • successThreshold: Threshold needed to mark the container healthy.

  • failureThreshold: Threshold needed to mark the container unhealthy.

Conclusion:

Startup probes are very helpful to determine our application has started correctly and make sure you give enough time for your application to startup. By using readiness probes you ensure that your application is routed only to containers that are fully prepared to handle requests. While the liveness probes ensure that the container is alive and responsive.

Now you should be able to check how kubernetes evaluate applications health status via probes.

If you found this post useful, give it a like👍

Repost♻️

Follow Bala for more such posts 💯🚀