0
0
Kubernetesdevops~10 mins

Probe failure and container restart behavior in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Probe failure and container restart behavior
Pod starts container
Kubelet runs probes
Probe success?
NoFailure count increments
Failure count >= threshold?
Container runs normally
Failure count >= threshold?
YesContainer restart triggered
No
Continue monitoring probes
This flow shows how Kubernetes runs health probes on containers, counts failures, and restarts containers when failures reach a limit.
Execution Sample
Kubernetes
livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  failureThreshold: 3
  periodSeconds: 5
Defines a liveness probe that checks /healthz every 5 seconds and restarts container after 3 failures.
Process Table
Check NumberProbe ResultFailure CountRestart TriggeredAction
1Success0NoContainer continues running
2Failure1NoMonitor continues
3Failure2NoMonitor continues
4Failure3YesContainer restart triggered
5Success0NoContainer runs after restart
💡 After 3 consecutive failures, container restarts and failure count resets
Status Tracker
VariableStartAfter Check 1After Check 2After Check 3After Check 4After Check 5
failureCount001230
containerStateRunningRunningRunningRunningRestartingRunning
Key Moments - 3 Insights
Why does the failure count reset after the container restarts?
Because when the container restarts (see row 4 in execution_table), Kubernetes resets the failure count to zero to start fresh monitoring.
Does a single probe failure immediately restart the container?
No, the container restarts only after failureCount reaches the failureThreshold (3 in this example), as shown in rows 2-4.
What happens if a probe succeeds after some failures?
The failure count resets to zero (see row 5), so the container is considered healthy again.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the failureCount after the 3rd probe check?
A1
B2
C3
D0
💡 Hint
Check the 'Failure Count' column at row 3 in the execution_table.
At which check number does the container restart get triggered?
A2
B3
C4
D5
💡 Hint
Look at the 'Restart Triggered' column in the execution_table.
If the failureThreshold was set to 2, when would the container restart occur?
AAfter check 2
BAfter check 3
CAfter check 4
DAfter check 5
💡 Hint
Compare failureCount with failureThreshold in the execution_table rows.
Concept Snapshot
Kubernetes probes check container health periodically.
Failures increment a failureCount.
When failureCount reaches failureThreshold, container restarts.
Success resets failureCount to zero.
This ensures unhealthy containers get restarted automatically.
Full Transcript
Kubernetes uses probes like livenessProbe to check if a container is healthy. Each probe runs periodically. If a probe fails, Kubernetes increases a failure count. When this count reaches a set threshold, Kubernetes restarts the container to fix issues. If a probe succeeds, the failure count resets to zero. This cycle helps keep containers running smoothly by restarting them only after repeated failures, not just one failure.