Skip to content
Rahul Shishodiaon GitHub LinkedIn profile

Container Probes

Probe types

ProbeWhen failsAction
LivenessUnhealthy while runningRestart container
ReadinessNot ready for trafficRemoved from Service endpoints
StartupSlow/failed startKill container; delays liveness until success
  • Order: startup runs first → then readiness + liveness concurrently
  • Readiness is most important in practice

Verification methods

MethodYAMLSuccess
Execexec.commandExit code 0
HTTPhttpGet path/portStatus 200–399
TCPtcpSocket.portConnection opens
gRPCgrpcgRPC health protocol
  • Use named ports in probes: port: nodejs-port

Timing (all probes)

FieldDefaultMeaning
initialDelaySeconds0Wait before first check
periodSeconds10Interval between checks
timeoutSeconds1Max check duration
failureThreshold3Failures before action
successThreshold1Successes to recover after fail

YAML examples

readinessProbe:
  httpGet:
    path: /
    port: nodejs-port
  initialDelaySeconds: 2
  periodSeconds: 8

livenessProbe:
  exec:
    command: ["/bin/sh", "-c", "test -f /tmp/healthy"]

startupProbe:
  httpGet:
    path: /healthz
    port: 8080
  failureThreshold: 30
  periodSeconds: 10    # 30 * 10s max startup window

kubectl

kubectl get po <n>        # READY 0/1 if readiness failing
kubectl describe po <n>   # probe config + events

Failures

SymptomCause
CrashLoopBackOffWrong liveness → restarts
No trafficWrong readiness: Pod stays, removed from endpoints

Exam tips

  • Liveness too aggressive on slow apps → CrashLoop: use startupProbe
  • Readiness failure ≠ Pod restart (only removed from Service)
  • httpGet must use correct path and port (named port preferred)