Skip to main content

Probe types and configuration

11 min read

Pod lifecycle overview · Checklist and references

Kubernetes Probe Deep Dive​

Three Probe Types and How They Work​

Kubernetes provides three types of probes to monitor Pod health.

Table 1. Purpose and behavior of the three probe types

Probe typePurposeAction on failureActivation timing
Startup ProbeVerify that application initialization is completeTerminate the container and restart according to restartPolicy (when failureThreshold is reached)Immediately after Pod startup
Liveness ProbeDetect application deadlocksRestart the containerAfter the Startup Probe succeeds
Readiness ProbeVerify readiness to receive trafficRemove from Service Endpoints (no restart)After the Startup Probe succeeds

Startup Probe: Protecting Applications with Slow Startup​

A Startup Probe delays Liveness and Readiness Probes until the application has fully started. It is recommended when initialization takes longer than the Liveness Probe can tolerate through its initialDelaySeconds and failureThreshold. Applications with slow startup, such as Spring Boot applications, JVM applications, and applications that load ML models, are typical candidates; whether one is actually needed depends on the measured initialization time and the Liveness Probe configuration rather than on the framework.

How it works:

  • Liveness and Readiness Probes remain disabled while the Startup Probe is running.
  • Startup Probe succeeds → Liveness and Readiness Probes are enabled.
  • Startup Probe fails (failureThreshold is reached) → the container restarts.

Liveness Probe: Detecting Deadlocks​

A Liveness Probe checks whether the application is alive. If it fails, kubelet restarts the container.

Use cases:

  • Detecting infinite loops and deadlocks
  • Unrecoverable application errors
  • Unresponsiveness caused by memory leaks

Cautions:

  • Do not include external dependencies (such as a database or Redis) in a Liveness Probe.
  • An external service failure can cause a cascading failure in which all Pods restart.

Readiness Probe: Controlling Incoming Traffic​

A Readiness Probe checks whether a Pod is ready to receive traffic. If it fails, the Pod is removed from the Service's Endpoints, but the container does not restart.

Use cases:

  • Checking connections to dependent services (databases and caches)
  • Verifying that initial data loading is complete
  • Gradually receiving traffic during deployment

Flow summary

  1. After the Init Container and main container start, the Startup Probe verifies that initialization is complete.
  2. The Liveness Probe determines whether to restart the container, and the Readiness Probe determines whether the Pod participates in Service Endpoints.
  3. Following a termination request, the container terminates after preStop execution, SIGTERM handling, and graceful shutdown.

Figure 1. Pod lifecycle and probe behavior flow

Expand the diagram to read labels and follow connections.
Diagram

Probe Mechanisms​

Kubernetes supports four probe mechanisms.

Table 2. Characteristics and suitable use cases by probe mechanism

MechanismDescriptionAdvantagesDisadvantagesSuitable use cases
httpGetSend an HTTP GET request and check for a 200-399 response codeStandard approach, straightforward implementationRequires an HTTP serverREST APIs, web services
tcpSocketCheck whether a connection to a TCP port can be establishedLightweight and fastCannot validate application logicgRPC, databases
execRun a command inside the container and check for exit code 0Flexible, supports custom logicHigh overheadBatch workers, file-based checks
grpcUse the gRPC Health Check Protocol (GA in K8s 1.27+)Native gRPC supportLimited to gRPC applicationsgRPC microservices

httpGet Example​

livenessProbe:
httpGet:
path: /healthz
port: 8080
httpHeaders:
- name: X-Custom-Header
value: HealthCheck
scheme: HTTP # Or HTTPS
initialDelaySeconds: 30
periodSeconds: 10

tcpSocket Example​

livenessProbe:
tcpSocket:
port: 5432 # PostgreSQL
initialDelaySeconds: 15
periodSeconds: 10

exec Example​

livenessProbe:
exec:
command:
- /bin/sh
- -c
- test -f /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5

grpc Example (Kubernetes 1.27+)​

livenessProbe:
grpc:
port: 9090
service: myservice # Optional
initialDelaySeconds: 10
periodSeconds: 5
gRPC Health Check Protocol

gRPC services must implement the gRPC Health Checking Protocol. Use google.golang.org/grpc/health for Go and the io.grpc:grpc-services artifact's io.grpc.protobuf.services.HealthStatusManager for Java.

Probe Timing Design​

Probe timing parameters determine the balance between failure detection speed and stability.

Table 3. Default values and recommended ranges for probe timing parameters

ParameterDescriptionDefaultRecommended range
initialDelaySecondsWait time between container startup and the first probe010-30s (can be 0 when using a Startup Probe)
periodSecondsInterval between probe executions105-15s
timeoutSecondsWait time for a probe response13-10s
failureThresholdNumber of consecutive failures required to declare failure3Liveness: 3, Readiness: 1-3, Startup: 30+
successThresholdNumber of consecutive successes required to declare success (must be 1 for Liveness and Startup; only Readiness may use a value greater than 1)11-2

Timing Design Formulas​

Approximate consecutive failure detection budget = failureThreshold × periodSeconds
Approximate minimum recovery time = (successThreshold - 1) × periodSeconds (additional intervals after the first success)

Examples:

  • failureThreshold: 3, periodSeconds: 10 → a consecutive failure detection budget of approximately 30 seconds
  • successThreshold: 2, periodSeconds: 5 → recovery is declared about 5 seconds after the first success (Readiness only)

Recommended Timing by Workload​

Table 4. Recommended probe timing settings by workload type

Workload typeinitialDelaySecondsperiodSecondsfailureThresholdRationale
Web services (Node.js, Python)1053Fast startup, requires rapid detection
JVM applications (Spring Boot)0 (with a Startup Probe)103Slow startup, protected by a Startup Probe
Databases (PostgreSQL)30105Long initialization time
Batch workers5152Periodic tasks, less aggressive detection
ML inference services0 (Startup: 60)103Long model loading time