Sobes.tech
Senior

What probes are available in Kubernetes? How do they differ?

sobes.tech AI

Answer from AI

In Kubernetes, there are three main types of probes used to check the health of containers:

  1. Liveness Probe — checks if the container is alive. If the check fails, kubelet restarts the container. This helps detect situations where the application is hung or in an incorrect state.

  2. Readiness Probe — checks if the container is ready to accept traffic. If the check fails, the container is temporarily removed from the services (Endpoints) so that no requests are sent to it.

  3. Startup Probe — used to verify the successful start of the application. If the application takes a long time to start, this probe prevents the container from being considered failed until the startup is complete. After a successful Startup Probe, liveness and readiness probes begin to operate.

Differences:

  • Liveness is responsible for restarting the container upon failure.
  • Readiness is responsible for the container's availability to handle requests.
  • Startup helps to correctly handle long application startup times, preventing premature restarts.

Example of a liveness probe in a manifest:

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

This will check the HTTP endpoint /healthz every 20 seconds, starting 15 seconds after the container starts.