Startup probe concept in Kubernetes - Time & Space Complexity
We want to understand how the startup probe affects the time it takes for a container to become ready.
How does the number of probe checks grow as the container startup time changes?
Analyze the time complexity of this startup probe configuration.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: example-container
image: example-image
startupProbe:
exec:
command:
- cat
- /tmp/healthy
failureThreshold: 5
periodSeconds: 10
This code sets a startup probe that runs a command every 10 seconds, up to 5 failures allowed before restart.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: The startup probe command execution every periodSeconds.
- How many times: Up to failureThreshold times if the probe keeps failing.
The number of probe checks grows linearly with the failureThreshold setting.
| Input Size (failureThreshold) | Approx. Operations (probe runs) |
|---|---|
| 3 | 3 probe checks |
| 5 | 5 probe checks |
| 10 | 10 probe checks |
Pattern observation: More allowed failures mean more probe executions before restart.
Time Complexity: O(n)
This means the number of probe executions grows directly with the failureThreshold value.
[X] Wrong: "The startup probe runs only once regardless of failureThreshold."
[OK] Correct: The probe runs repeatedly until it succeeds or reaches failureThreshold, so the number of runs depends on failureThreshold.
Understanding how probes work and their timing helps you explain container readiness and failure handling clearly in real projects.
"What if we change periodSeconds to a smaller value? How would the time complexity of probe executions change?"