Probe timing parameters (initialDelay, period, timeout) in Kubernetes - Time & Space Complexity
When Kubernetes checks if a container is healthy, it uses probes with timing settings. Understanding how these timings affect the checking process helps us see how often and how long these checks take.
We want to know how the number of probe checks grows as the pod runs longer.
Analyze the time complexity of the following Kubernetes liveness probe configuration.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: example-container
image: example-image
livenessProbe:
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 2
httpGet:
path: /health
port: 8080
This config sets when and how often Kubernetes checks if the container is alive using HTTP requests.
- Primary operation: Kubernetes sends a liveness HTTP request probe repeatedly.
- How many times: After waiting initialDelaySeconds, it repeats every periodSeconds until the pod stops.
As the pod runs longer, the number of probe checks grows steadily over time.
| Input Size (seconds running) | Approx. Number of Probes |
|---|---|
| 10 | 0 (waiting initial delay) |
| 100 | 18 probes ((100-10)/5) |
| 1000 | 198 probes ((1000-10)/5) |
Pattern observation: The number of probes grows linearly with time after the initial delay.
Time Complexity: O(n)
This means the number of probe checks grows directly in proportion to how long the pod runs after the initial delay.
[X] Wrong: "The probes happen instantly and only once."
[OK] Correct: Probes repeat regularly after the initial delay, so they happen many times over the pod's life.
Understanding how probe timings affect repeated checks shows you can reason about system behavior over time, a useful skill for managing real-world Kubernetes workloads.
"What if we change periodSeconds to a smaller value? How would the time complexity change?"