DevOpsJanuary 31, 2026 10 min read

How to Monitor Kubernetes Pod Liveness and Readiness

Learn how to set up Kubernetes liveness and readiness probes. Ensure your pods are healthy and ready to serve traffic with proper probe configuration.

WizStatus Team
Author

Kubernetes probes are essential for maintaining healthy applications. Liveness probes restart unhealthy pods, while readiness probes control traffic routing. Here's how to configure them properly.

Understanding Kubernetes Probes

Three Types of Probes

ProbePurposeFailure Action
LivenessIs the container alive?Restart container
ReadinessCan it handle traffic?Remove from service
StartupHas it started?Block other probes

When to Use Each

  • Liveness: Detect deadlocks, infinite loops, stuck processes
  • Readiness: Wait for dependencies, handle graceful degradation
  • Startup: Allow slow-starting applications time to initialize

Configuring Liveness Probes

HTTP Liveness Probe

apiVersion: v1
kind: Pod
metadata:
  name: my-app
spec:
  containers:
  - name: app
    image: my-app:latest
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
      initialDelaySeconds: 15
      periodSeconds: 10
      timeoutSeconds: 5
      failureThreshold: 3
      successThreshold: 1

TCP Liveness Probe

For services without HTTP endpoints:

livenessProbe:
  tcpSocket:
    port: 3306
  initialDelaySeconds: 30
  periodSeconds: 10

Command Liveness Probe

For custom health checks:

livenessProbe:
  exec:
    command:
    - cat
    - /tmp/healthy
  initialDelaySeconds: 5
  periodSeconds: 5

Configuring Readiness Probes

HTTP Readiness Probe

readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 5
  timeoutSeconds: 3
  failureThreshold: 3

Different Endpoints for Different Probes

spec:
  containers:
  - name: app
    ports:
    - containerPort: 8080
    livenessProbe:
      httpGet:
        path: /healthz  # Basic alive check
        port: 8080
    readinessProbe:
      httpGet:
        path: /ready    # Full dependency check
        port: 8080

Startup Probes for Slow Applications

startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  failureThreshold: 30
  periodSeconds: 10
  # Allows up to 5 minutes (30 * 10s) for startup

Implementing Health Endpoints

Liveness Endpoint (Simple)

// Go
func livenessHandler(w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(http.StatusOK)
    w.Write([]byte("OK"))
}

Readiness Endpoint (With Dependency Checks)

func readinessHandler(w http.ResponseWriter, r *http.Request) {
    // Check database connection
    if err := db.Ping(); err != nil {
        w.WriteHeader(http.StatusServiceUnavailable)
        return
    }

    // Check Redis connection
    if err := redis.Ping().Err(); err != nil {
        w.WriteHeader(http.StatusServiceUnavailable)
        return
    }

    w.WriteHeader(http.StatusOK)
}

Python Flask Example

from flask import Flask
import psycopg2

app = Flask(__name__)

@app.route('/healthz')
def liveness():
    return 'OK', 200

@app.route('/ready')
def readiness():
    try:
        conn = psycopg2.connect(DATABASE_URL)
        conn.close()
        return 'Ready', 200
    except:
        return 'Not Ready', 503

Probe Parameters Explained

ParameterDescriptionRecommended
initialDelaySecondsWait before first probeApp startup time
periodSecondsTime between probes10s
timeoutSecondsMax probe duration3-5s
successThresholdSuccesses to be healthy1
failureThresholdFailures to be unhealthy3

Common Mistakes to Avoid

1. Too Aggressive Probes

# BAD: Will kill pods during normal load spikes
livenessProbe:
  timeoutSeconds: 1
  failureThreshold: 1
  periodSeconds: 1

2. Checking External Dependencies in Liveness

// BAD: Don't check external services in liveness
func livenessHandler(w http.ResponseWriter, r *http.Request) {
    if err := externalAPI.Ping(); err != nil {
        w.WriteHeader(503)  // This will restart the pod!
        return
    }
}

3. Same Endpoint for Both Probes

The liveness endpoint should be simpler than readiness.

External Monitoring

Monitor Kubernetes Services

In addition to probes, monitor your exposed services:

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080

Set up external monitoring for:

  • Load balancer endpoint
  • Ingress endpoints
  • Critical API routes

Probe Configuration Checklist

  • Liveness probe configured
  • Readiness probe configured
  • Startup probe for slow apps
  • Appropriate timeouts set
  • Failure thresholds tuned
  • Health endpoints implemented
  • External dependencies not in liveness
  • External monitoring configured
  • Alerting set up for pod restarts
  • Dashboards showing pod health
WizStatus monitors your Kubernetes service endpoints externally. Combined with internal probes, you get complete visibility into your cluster health with instant alerts.

Related Articles

Alert Fatigue Prevention: Strategies for Effective Monitoring
Best Practices

Alert Fatigue Prevention: Strategies for Effective Monitoring

Combat alert fatigue with proven prevention strategies. Learn how to reduce noise, prioritize alerts, and maintain effective monitoring without overwhelming your team.
10 min read
Chaos Engineering Monitoring: Measure Resilience in Action
DevOps

Chaos Engineering Monitoring: Measure Resilience in Action

Learn to monitor chaos engineering experiments effectively. Discover metrics, observability patterns, and analysis techniques for resilience testing.
12 min read
CI/CD Pipeline Monitoring: Ensure Fast, Reliable Deployments
DevOps

CI/CD Pipeline Monitoring: Ensure Fast, Reliable Deployments

Master CI/CD pipeline monitoring for reliable software delivery. Learn key metrics, alerting strategies, and optimization techniques for deployment pipelines.
11 min read

Start monitoring your infrastructure today

Put these insights into practice with WizStatus monitoring.

Try WizStatus Free