Probe types

ProbeFailure ActionPurpose
livenessProbeRestart containerApp alive? Recover from deadlocks
readinessProbeRemove from Service endpointsApp ready for traffic?
startupProbeRestart container (blocks liveness/readiness)Slow-starting apps; delays other probes until passes
  • Order: startup first → then readiness + liveness concurrently

All three probes with all config fields

spec:
  containers:
  - name: app
    image: myapp:1.0
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
      initialDelaySeconds: 10   # wait before first probe
      periodSeconds: 10         # how often to probe
      timeoutSeconds: 1         # probe timeout
      failureThreshold: 3       # failures before action
      successThreshold: 1       # successes to mark healthy (liveness: always 1)
    readinessProbe:
      tcpSocket:
        port: 5432
      initialDelaySeconds: 5
      periodSeconds: 5
      failureThreshold: 3
      successThreshold: 1       # readiness: can be >1
    startupProbe:
      exec:
        command:
        - cat
        - /tmp/ready             # exit 0 = success
      failureThreshold: 30      # 30 × 10s = 5 min for slow startup
      periodSeconds: 10

Verification methods

MethodYAMLSuccess
Execexec.commandExit code 0
HTTPhttpGet path/portStatus 200–399
TCPtcpSocket.portConnection opens
gRPCgrpc.portgRPC health protocol (k8s 1.24+)

gRPC probe

livenessProbe:
  grpc:
    port: 9090
    service: ""            # optional
  initialDelaySeconds: 10
  periodSeconds: 10

httpGet with HTTPS

livenessProbe:
  httpGet:
    path: /healthz
    port: 8443
    scheme: HTTPS
    httpHeaders:
    - name: Custom-Header
      value: Awesome

Timing defaults

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

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 gotchas

  • readinessProbe failing ≠ restart: Pod stays Running but removed from Service endpoints; auto-rejoins when fixed
  • Liveness too aggressive on slow apps → CrashLoop: use startupProbe
  • httpGet: correct path and port (named port preferred)