Probes

A Probe is a diagnostic mechanism that Kubernetes uses to check the health of a container. They run periodically and report the status back to the kubelet. Based on the probe result, Kubernetes can decide to:

  • Restart a container

  • Stop routing traffic to a container

  • Mark the Pod as ready or not ready

Types of Probes

Liveness probe

  • Checks if the container is still running properly.

  • If it fails, Kubernetes restarts the container.

  • Example: an app is running but deadlocked → liveness probe fails → kubelet restarts it.

Ensures apps that get stuck or crash get restarted automatically.

Example

Readiness probe

  • Checks if the container is ready to accept traffic.

  • If it fails, the Pod is marked unready → Service will stop sending traffic to it.

  • Example: your app takes 30 seconds to load caches. Until ready probe passes, no traffic is sent.

Ensures traffic is only routed to healthy Pods.

Startup probe

  • Checks if the container has started successfully.

  • Especially useful for apps with slow startup times.

  • Disables liveness and readiness checks until it succeeds.

  • Prevents Kubernetes from killing apps that just need more time to boot.

Ensures slow apps don’t get killed prematurely during initialization.

Probe Actions

Probes can use one of these mechanisms to check health:

httpGet

Hits an HTTP endpoint in your container:

tcpSocket

Tries to open a TCP connection:

exec

Runs a command inside the container:

Probe Parameters

  • initialDelaySeconds: how long to wait before starting checks.

  • periodSeconds: how often to run the probe.

  • timeoutSeconds: how long to wait before probe times out.

  • successThreshold: how many successes before marking healthy.

  • failureThreshold: how many failures before marking unhealthy.

Example

Last updated