Sobes.tech
Senior

What are readiness and liveness probes in Kubernetes?

sobes.tech AI

Answer from AI

Readiness and liveness probes are mechanisms in Kubernetes for checking the status of containers.

  • Liveness probe checks if the container is alive. If the check fails, Kubernetes restarts the container. This helps automatically recover containers that are "hung" or in an incorrect state.

  • Readiness probe checks if the container is ready to accept traffic. If the check fails, Kubernetes removes this container from the list of available containers to serve requests, but does not restart it.

Example of configuring liveness and readiness probes in a Pod manifest:

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

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

Thus, liveness is responsible for restarting the container on failure, and readiness manages the container's availability to handle requests.