Published: 2026-06-01 โ€ข Updated: 2026-07-05

Liveness, Readiness, and Startup Probes in Kubernetes: Complete Real-Time Production Guide

Kubernetes is designed to keep applications reliable, available, and self-healing. But Kubernetes cannot automatically know whether your application is healthy unless you tell it how to check. This is where Liveness, Readiness, and Startup Probes become extremely important.

Your base content explains the three probes clearly. This enhanced version adds deeper production explanations, real-time banking and e-commerce examples, flow diagrams, common mistakes, troubleshooting, and interview-friendly notes. :contentReference[oaicite:0]{index=0}


Why Kubernetes Probes Are Needed?

A container may be running, but that does not always mean the application is working correctly.

For example:

  • The process is running but the application is stuck
  • The app started but database connection is not ready
  • The API is alive but cannot serve traffic
  • The application needs more startup time
  • The service is overloaded and temporarily unavailable

Without probes, Kubernetes may continue sending traffic to a broken application.

Problem Without Probes

[ User Request ]
      |
      v
[ Kubernetes Service ]
      |
      v
[ Broken Pod Still Running ]
      |
      v
User Gets Error

Solution With Probes

[ Kubernetes Probe ]
      |
      v
Checks Application Health
      |
      +-- Healthy   -> Send Traffic
      |
      +-- Unhealthy -> Stop Traffic / Restart Container

Types of Kubernetes Probes

Probe Purpose Action on Failure
Liveness Probe Checks whether container is alive Restarts container
Readiness Probe Checks whether app can receive traffic Removes Pod from Service endpoints
Startup Probe Checks whether slow app has started Delays liveness/readiness checks

1. Liveness Probe

A Liveness Probe checks whether the application is still alive. If the liveness probe fails repeatedly, Kubernetes assumes the container is unhealthy and restarts it.

This is useful when the application hangs, deadlocks, or stops responding even though the container process is technically still running.

Liveness Probe Flow

Container Running
      |
      v
Liveness Probe Checks Health
      |
      +-- Success -> Continue Running
      |
      +-- Failure -> Restart Container

HTTP Liveness Probe Example

apiVersion: v1
kind: Pod

metadata:
  name: payment-liveness-demo

spec:
  containers:
  - name: payment-container
    image: payment-api:v1

    livenessProbe:
      httpGet:
        path: /actuator/health/liveness
        port: 8080

      initialDelaySeconds: 20
      periodSeconds: 10
      failureThreshold: 3

This probe checks the health endpoint every 10 seconds after waiting 20 seconds.


Real-Time Banking Example for Liveness Probe

Imagine a banking transaction service that processes fund transfers. Due to a thread deadlock, the application stops responding but the Java process still runs.

Without liveness probe:

  • The broken Pod remains running
  • Users continue getting timeout errors
  • Manual restart is required

With liveness probe:

  • Kubernetes detects failure
  • Container is restarted automatically
  • Service recovers faster

2. Readiness Probe

A Readiness Probe checks whether the application is ready to receive traffic.

This is different from liveness. An application may be alive but not ready.

For example, a Spring Boot application may be running, but:

  • Database connection is not established
  • Redis is unavailable
  • Kafka connection is still initializing
  • Configuration is still loading

Readiness Probe Flow

Pod Starts
   |
   v
Readiness Probe Runs
   |
   +-- Success -> Pod added to Service endpoints
   |
   +-- Failure -> Pod removed from Service endpoints

Readiness Probe YAML Example

apiVersion: v1
kind: Pod

metadata:
  name: payment-readiness-demo

spec:
  containers:
  - name: payment-container
    image: payment-api:v1

    readinessProbe:
      httpGet:
        path: /actuator/health/readiness
        port: 8080

      initialDelaySeconds: 10
      periodSeconds: 5
      failureThreshold: 3

Real-Time E-Commerce Example for Readiness Probe

Suppose an e-commerce checkout service starts successfully, but it has not yet connected to the payment gateway.

If traffic reaches this Pod too early:

  • Checkout may fail
  • Payment requests may timeout
  • Orders may remain incomplete

Readiness probe prevents this problem by keeping the Pod out of the Service endpoint list until it is truly ready.

Traffic Protection Flow

[ Checkout Pod Started ]
          |
          v
Database / Payment Gateway Not Ready
          |
          v
Readiness Probe Fails
          |
          v
Service Does Not Send Traffic
          |
          v
Application Becomes Ready
          |
          v
Readiness Probe Passes
          |
          v
Traffic Starts

3. Startup Probe

A Startup Probe is used for applications that take longer to start.

Some applications need extra startup time because they load:

  • Large configuration files
  • Machine learning models
  • Cache data
  • Database migration scripts
  • Reporting datasets

Without a startup probe, Kubernetes may think the app is unhealthy and restart it too early.

Startup Probe Flow

Container Starts
      |
      v
Startup Probe Runs
      |
      +-- Not Ready Yet -> Keep Waiting
      |
      +-- Success -> Enable Liveness and Readiness Probes

Startup Probe YAML Example

apiVersion: v1
kind: Pod

metadata:
  name: reporting-startup-demo

spec:
  containers:
  - name: reporting-container
    image: reporting-service:v1

    startupProbe:
      httpGet:
        path: /startup
        port: 8080

      failureThreshold: 30
      periodSeconds: 10

This gives the application up to 5 minutes to start.


Real-Time Reporting Service Example

In a banking system, a reporting service may load millions of transaction records or initialize heavy analytics components during startup.

If Kubernetes starts liveness checks too early:

  • The app may be restarted repeatedly
  • The Pod may enter CrashLoopBackOff
  • The service never becomes available

Startup probe protects slow applications from premature restarts.


Liveness vs Readiness vs Startup

Feature Liveness Readiness Startup
Main Question Is app alive? Can app receive traffic? Has app started?
Failure Action Restart container Remove from traffic Wait before other probes
Best Use Deadlock detection Traffic safety Slow startup apps
Production Impact Self-healing Zero bad traffic Avoid false restarts

Probe Types in Kubernetes

Kubernetes supports three common ways to perform probes.

1. HTTP Probe

httpGet:
  path: /health
  port: 8080

Best for web applications and REST APIs.

2. TCP Probe

tcpSocket:
  port: 8080

Best when you only need to verify that a port is accepting connections.

3. Exec Probe

exec:
  command:
  - cat
  - /tmp/healthy

Best for custom checks inside the container.


Spring Boot Actuator Probe Example

For Spring Boot applications, Actuator endpoints are commonly used for Kubernetes probes.

management.endpoint.health.probes.enabled=true
management.health.livenessstate.enabled=true
management.health.readinessstate.enabled=true

Recommended Endpoints

  • /actuator/health/liveness
  • /actuator/health/readiness

Complete Deployment Example with All Probes

apiVersion: apps/v1
kind: Deployment

metadata:
  name: payment-service

spec:
  replicas: 3

  selector:
    matchLabels:
      app: payment

  template:
    metadata:
      labels:
        app: payment

    spec:
      containers:
      - name: payment-container
        image: payment-service:v1

        ports:
        - containerPort: 8080

        startupProbe:
          httpGet:
            path: /actuator/health
            port: 8080
          failureThreshold: 30
          periodSeconds: 10

        livenessProbe:
          httpGet:
            path: /actuator/health/liveness
            port: 8080
          initialDelaySeconds: 20
          periodSeconds: 10
          failureThreshold: 3

        readinessProbe:
          httpGet:
            path: /actuator/health/readiness
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 5
          failureThreshold: 3

Common Mistakes

1. Using Liveness Probe for Database Dependency

If database is temporarily down, liveness probe should not always restart the app. Use readiness for dependency availability.

2. No Startup Probe for Slow Applications

Slow applications may restart repeatedly before becoming ready.

3. Very Aggressive Probe Intervals

Checking too frequently may add unnecessary load.

4. Same Endpoint for All Probes

Liveness and readiness should usually check different conditions.

5. Ignoring Probe Failures

Probe failures often reveal real production problems.


Production Debugging Workflow

Step 1: Check Pods
kubectl get pods

Step 2: Describe Pod
kubectl describe pod pod-name

Step 3: Check Events
kubectl get events

Step 4: View Logs
kubectl logs pod-name

Step 5: Test Health Endpoint
kubectl exec -it pod-name -- curl localhost:8080/actuator/health

Step 6: Review Probe Configuration

Real-Time Production Failure Example

A payment service enters CrashLoopBackOff after deployment.

Possible Cause

  • Liveness probe starts too early
  • Application needs 90 seconds to initialize
  • Probe starts after 10 seconds
  • Kubernetes kills container repeatedly

Fix

  • Add startup probe
  • Increase initialDelaySeconds
  • Use correct health endpoint

Interview Questions

Q1: What is a Liveness Probe?

It checks whether a container is alive. If it fails, Kubernetes restarts the container.

Q2: What is a Readiness Probe?

It checks whether a Pod is ready to receive traffic.

Q3: What is a Startup Probe?

It gives slow-starting applications enough time to initialize before liveness checks begin.

Q4: What happens if readiness probe fails?

The Pod is removed from Service endpoints until it becomes ready again.

Q5: What happens if liveness probe fails?

Kubernetes restarts the container.


Interview Trap Questions

Should liveness probe check database connection?

Usually no. Database dependency issues are better handled by readiness probes.

Can readiness failure restart a container?

No. It only removes the Pod from traffic.

Can startup probe prevent CrashLoopBackOff?

Yes, when the issue is premature liveness failure during slow startup.

Are probes mandatory?

No, but they are strongly recommended for production workloads.


Recommended Learning Path


Summary

Liveness, Readiness, and Startup Probes are essential for building reliable Kubernetes applications.

Liveness probes help Kubernetes restart broken containers. Readiness probes prevent traffic from reaching unavailable Pods. Startup probes protect slow-starting applications from premature restarts.

In real production systems such as banking, e-commerce, healthcare, and SaaS platforms, probes improve availability, reduce downtime, and protect users from broken application instances.

A well-designed Kubernetes application should always use probes carefully with realistic timing, correct endpoints, and proper monitoring.

About the Author

Naresh Kumar

Naresh Kumar

Senior Java Backend Engineer experienced in Banking, Payments, ISO 20022, Spring Boot, Microservices, Kafka, Docker, Kubernetes, AWS and Cloud Native Systems.

Built enterprise payment solutions, transaction processing systems, API platforms and scalable microservices used in production.

LinkedIn Profile