Investigate the restart before extending every timeout
A slow-starting container repeatedly disappears before initialization finishes. That symptom suggests a startup allowance problem, but it does not identify the cause. A failed HTTP request, an exhausted probe threshold and a process exiting on its own are different pieces of evidence.
A Kubernetes startup probe decides whether this container incarnation has completed startup. Until it succeeds, the kubelet holds back that container's liveness and readiness probes. After startup succeeds, ongoing health and traffic admission need their own checks. The official probe contract defines those separate jobs.
Our executable artifact is a scripted decision model, not a Kubernetes cluster test. It consumes Boolean probe outcomes and asserts eight sequences. One sequence contains four liveness failures without a termination decision because no three failures occur consecutively. That distinction is useful before changing a timeout or treating an event count as a restart counter.
Assign each probe the action it can justify
Startup asks whether initialization has completed. Liveness asks whether restarting this container is a reasonable response to its condition. Readiness asks whether it can serve its intended traffic now. A temporary dependency failure can change readiness without proving that a process restart would repair anything.
When a startup or liveness failure reaches its threshold, the kubelet terminates the affected container. What happens next follows its restart policy. A readiness failure marks it not ready and influences matching Service traffic. It does not restart the container. These are container checks within a Pod, not instructions to replace an entire Deployment.
Readiness is also not a universal work-admission switch. A queue consumer can continue fetching messages while an HTTP readiness endpoint reports failure. The worker shutdown and drain guide covers that separate admission path. Treat existing connections and traffic propagation through your actual delivery path as additional behavior to verify.
Follow the one-time startup handoff
In the successful-startup model case, four startup failures precede one success with a failure threshold of five. Ten supplied liveness/readiness outcomes are marked gated, so they never enter either counter. After the handoff, liveness can run and readiness still needs its own successful results.
Startup success is a latch for this container incarnation. It is not an ongoing readiness verdict. Another model case supplies a startup success followed by a startup failure. The second startup outcome is ignored because that check has completed. A new container start gets a new startup lifecycle. Review the Pod lifecycle documentation when interpreting container states and restarts.
Make the endpoint and threshold choices visible
containers:
- name: api
ports:
- name: health
containerPort: 8080
startupProbe:
httpGet:
path: /startupz
port: health
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 5
successThreshold: 1
livenessProbe:
httpGet:
path: /livez
port: health
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
successThreshold: 1
readinessProbe:
httpGet:
path: /readyz
port: health
periodSeconds: 5
timeoutSeconds: 1
failureThreshold: 2
successThreshold: 2The application must implement these paths. A declared containerPort does not create a listener or health handler. The named health port makes the relationship explicit for HTTP. A wrong target port or path still fails. Keep successThreshold at one for startup and liveness. Readiness may require multiple consecutive successes before returning to ready.
The sample separates the startup allowance from ongoing failure detection. Its values are examples to review against your application, not recommended production defaults or numbers established by the model. The configuration task explains the supported fields and mechanisms.
Treat the startup budget as a planning allowance
The common planning expression is failureThreshold × periodSeconds. Five attempts spaced by a ten-second period suggest a fifty-second allowance, but that multiplication is not a promise that termination happens at exactly second fifty. Probe scheduling, request duration and termination grace are separate parts of the lifecycle.
initialDelaySeconds postpones the beginning of a check. periodSeconds controls its configured interval. timeoutSeconds limits an individual probe attempt. It is not the full initialization budget. The documented defaults are zero seconds of initial delay, a ten-second period, a one-second timeout and three consecutive failures. Read the rules for the Kubernetes version you actually operate.
Measure initialization from the relevant container lifecycle boundary. Image pulling and scheduling are different phases. A startup probe cannot repair either one. Do not add image-pull time to an application handler trace and conclude that its startup threshold was consumed. Our model executes no clock, initial delay, period scheduling or image pull.
Collect slow successful starts as well as failed starts. Choose enough startup allowance for a supported initialization path, then keep a separate liveness policy for an application that stops making progress later. Raising every liveness timeout to accommodate cold starts also delays detection after startup.
Count consecutive failures, not every failed event
For the four liveness-only sequences below, the model uses failureThreshold: 3. F means a supplied failure and S means a success. A success resets the failure streak. The table contains model decisions, not kubelet measurements or container restart counts.
| Supplied sequence | Consumed failures | Largest failure streak | Termination decisions |
|---|---|---|---|
| F F F | 3 | 3 | 1 |
| F F S F F S | 4 | 2 | 0 |
| F F S F F F | 5 | 3 | 1 |
| F S F S F S | 3 | 1 | 0 |
The interrupted sequence has four failed outcomes but never reaches a streak of three. The late-failure sequence reaches its threshold only after a success has reset the earlier streak. Our exhausted-startup case instead fails three times and records termination before a later supplied success could rescue that incarnation.
Readiness has its own recovery rule. The modeled readiness sequence S, S, F, F, F, S, S starts not ready, becomes ready after two successes, becomes not ready after two failures and needs two new successes to recover. It makes no termination decision. Do not combine counters across probe types or container incarnations.
Ask whether a restart can repair this failure
A cheap local startup check can report that required initialization has finished. A liveness check should identify a condition for which restarting the container is a useful recovery action. Making every liveness request depend on a shared database can turn a database outage into repeated application restarts without repairing the database.
Readiness should reflect the service contract you intend to offer. If useful degraded work remains possible, an indiscriminate dependency check can remove healthy capacity. If serving a request would violate that contract, returning ready is misleading. Write down the minimum serving conditions and the owner of each dependency decision.
Check the actual listener address and Pod target. A handler bound only to loopback is not automatically reachable through the Pod IP. A protected endpoint may reject the kubelet with an authentication response. Keep health checks inexpensive and avoid placing secrets or customer records in their response bodies. Successful TCP connection setup alone cannot prove that an HTTP handler is usable.
Verify the selected probe mechanism
HTTP checks evaluate a GET against a configured path and port. Response status codes from 200 through 399 count as success. A 404 usually points to a route mismatch, while a 503 can be an intentional not-started result. Redirect behavior needs its own review: a login redirect is not proof that application startup completed.
TCP checks establish whether a port accepts a connection. Exec checks run a command in the container and use its exit status. The command array is not an implicit shell. Shell operators need an explicitly chosen shell that exists in the image. Repeated exec checks also create processes, so include their cost in a dense workload review.
A gRPC probe needs the gRPC health-check protocol and a numeric port. Named ports supported by HTTP/TCP are not supported there. Do not assume a working HTTP health path proves the gRPC contract. The fixture below models already-classified outcomes and implements none of these protocol handlers.
Gather evidence from the failing incarnation
kubectl --context YOUR_CONTEXT -n YOUR_NAMESPACE describe pod YOUR_POD
kubectl --context YOUR_CONTEXT -n YOUR_NAMESPACE logs YOUR_POD -c YOUR_CONTAINER
kubectl --context YOUR_CONTEXT -n YOUR_NAMESPACE logs YOUR_POD -c YOUR_CONTAINER --previous
kubectl --context YOUR_CONTEXT -n YOUR_NAMESPACE get pod YOUR_POD -o yamlStart with the event message and container state. Connection refused, an HTTP status failure and context deadline exceeded suggest different investigations. Confirm the target path, port and mechanism, then correlate initialization logs with container identity and restart count. Previous-container logs are especially useful when the current incarnation starts a new attempt.
A timeout can reflect a slow handler, resource pressure or network behavior. A refusal can reflect a listener that has not started or the wrong target. Those messages narrow the investigation. They do not prove a single cause. The running-Pod debugging task gives the operational evidence path.
If readiness never runs, first establish whether startup succeeded. If the container was OOMKilled or its process exited, inspect that termination reason rather than attributing every restart to a probe. Event aggregation is not a complete chronological trace of individual failed attempts.
Keep shutdown grace separate from failure detection
Reaching a startup or liveness failure threshold begins a container termination path. It does not establish that cleanup finished immediately. Kubernetes supports probe-level terminationGracePeriodSeconds for startup and liveness, with the Pod-level value as the broader default. That probe-level field is not permitted for readiness.
Review the workload's stop behavior, lifecycle hooks and restart policy together. A preStop hook and application drain consume the relevant termination lifecycle. They are not independent unlimited budgets. Our model stops at a termination decision. It sends no signal, runs no hook and implements no restart backoff.
The Pod termination rules and the existing worker-drain material cover the next boundary. A probe check should not be presented as evidence that in-flight business work survived that boundary.
Separate container startup from rollout progress
A successful startup probe does not by itself make a Deployment available. Readiness, any applicable readiness gates and controller rules still matter. minReadySeconds describes how long a new Pod must remain ready for the controller's availability accounting. progressDeadlineSeconds concerns rollout progress, not an individual probe request.
Review maxSurge and maxUnavailable against real capacity while new instances initialize. A long startup allowance can coexist with an insufficient rollout deadline or a readiness condition that never succeeds. The Deployment documentation owns those controller rules.
Keep a rollout check for useful service behavior after startup. The canary rollback-gates guide covers release acceptance beyond a healthy process. No Deployment, Service, EndpointSlice or canary controller was executed by this article's fixture.
Reproduce the decisions without a cluster
Download the Python decision model and saved results. Run the standard-library-only script locally:
python3 experiment.py > actual.jsonEight assertion-backed cases consume 41 of 53 supplied results. Ten supplied results are gated before startup, one startup result is ignored after success and one later success is ignored after termination. The two executions produced byte-identical JSON. The chart reads the first four cases directly from that file.
This is a review aid for decision sequences. It does not replace an actual cluster test of endpoint reachability, result classification, probe scheduling, restart policy or traffic propagation. Reproduce those properties on the reviewed Kubernetes version and delivery path before using the manifest in a release.
Keep adjacent systems in their own investigation
Spring Boot Actuator, Quarkus, ASP.NET Core, Helm charts and service meshes add endpoint or configuration contracts. Managed platforms such as EKS, AKS and GKE add their own deployment environment. This article supplies no tested framework recipe, mesh exception or provider-specific configuration.
The application circuit breaker's recovery probes are another state machine. Its permitted calls and late outcomes belong to the HALF_OPEN admission guide, not the kubelet's health checks. Keep both sets of counters labeled by the decision they actually control.
Before changing the startup settings, retain the failing incarnation's evidence, state which condition a restart can repair and test the handoff into readiness. After the change, verify both slow successful startup and a genuine steady-state failure. That closes the investigation more usefully than a larger timeout alone.
Sources
Documentation checked .

Continue the conversation
Comments (0)