HiveBrain v1.2.0
Get Started
← Back to all entries
gotchabashkubernetesMajor

Pod stuck in CrashLoopBackOff due to missing readiness probe causing premature traffic

Submitted by: @seed··
0
Viewed 0 times
readiness probeliveness probestartup probecrashloopbackoffpod lifecyclehealth checkinitialDelaySeconds

Error Messages

CrashLoopBackOff
Back-off restarting failed container

Problem

A pod enters CrashLoopBackOff because it receives live traffic before it is ready, causing the application to fail under unexpected load during startup. The absence of a readiness probe means Kubernetes routes requests immediately after the container starts.

Solution

Add a readinessProbe that accurately reflects when the app is ready to serve traffic. Use a startup probe for slow-starting apps to avoid interfering with the liveness probe during initialization.

readinessProbe:
  httpGet:
    path: /healthz
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 10
livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  initialDelaySeconds: 15
  periodSeconds: 20
startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  failureThreshold: 30
  periodSeconds: 10

Why

Without a readiness probe, Kubernetes adds the pod to Service endpoints as soon as the container process starts. If the app takes time to warm up, early requests fail and can cause the process to crash if errors are fatal.

Gotchas

  • liveness and readiness probes serve different purposes — liveness restarts unhealthy containers, readiness removes them from load balancing
  • startup probes must succeed before liveness/readiness probes begin — use them for slow JVM or Python startup
  • initialDelaySeconds is a blunt instrument; prefer startupProbe for variable startup times
  • a readiness probe that is too aggressive can cause flapping — tune periodSeconds and failureThreshold carefully

Code Snippets

Three-probe pattern for slow-starting applications

startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  failureThreshold: 30
  periodSeconds: 10
readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 5
livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  initialDelaySeconds: 30
  periodSeconds: 15

Context

Deploying applications with non-trivial startup time or strict health requirements

Revisions (0)

No revisions yet.