A database outage should not automatically become a restart loop across every application replica. A health check can produce that result if its failure triggers the wrong recovery action. Define what the platform should do with each signal before choosing the endpoint that supplies it.
The example is an HTTP document service running on Kubernetes, with a required database and an optional recommendation provider. Its endpoint contracts, illustrative timing calculation, and failure exercise show how to decide whether a failing replica needs more startup time, less traffic, or a restart.
Start with the action each signal controls
The Kubernetes probe documentation distinguishes startup, liveness, and readiness. A failed liveness probe can trigger a container restart. Readiness controls whether a Pod is considered ready to receive Service traffic. A startup probe delays the other probes until startup succeeds.
Write a sentence describing when each action helps this application. Restarting may help a process that cannot make progress because its internal state is stuck. Removing a replica from ordinary traffic may help when that replica cannot serve requests correctly. Allowing additional startup time may help a process doing expected initialization.
For each sentence, identify an observation that distinguishes the condition. A process responding to a trivial endpoint may still have a broken worker subsystem. Conversely, a slow dependency may make a deep endpoint fail while the process remains capable of recovering without a restart.
Keep the health response small and free of internal diagnostics. Operators can use protected telemetry for investigation; the probe caller generally needs a bounded result. Exposing database names, connection strings, or stack traces adds disclosure without clarifying the recovery action.
Decide which dependencies justify removing traffic
For the synthetic service, consider the required database first. If every meaningful request requires it and there is no useful degraded mode, database availability may inform readiness. Explain the effect when all replicas observe the same outage: taking every replica out of traffic does not repair the database.
Review the optional recommendation provider differently. If the service can return its main result without recommendations, readiness should reflect that supported degraded behavior. Restarting or withdrawing the whole application because this provider is unavailable can turn a limited feature failure into a broader outage.
These are application-specific recommendations. Capture them in a dependency table maintained with the service: dependency, affected user operation, supported degradation, and intended platform response. Revisit the table when a formerly optional dependency becomes necessary for a core operation.
Bound probe work independently of ordinary requests. Avoid letting a health check occupy an expensive database connection or enqueue more work every time the platform polls. If the implementation reports cached dependency state, define its maximum age and verify how it behaves when the underlying check stops updating.
Budget startup from observed initialization
Give the application three explicit endpoint contracts. In this example, /startupz succeeds after local initialization has finished, /livez succeeds while the process can make progress, and /readyz succeeds when a new document request can be served. A failed optional recommendation lookup does not change any of those results because returning a document without recommendations is supported.
The following is an illustrative fragment inside one container specification, not a complete Deployment or a workload recommendation:
ports:
- name: http
containerPort: 8080
startupProbe:
httpGet:
path: /startupz
port: http
periodSeconds: 5
timeoutSeconds: 1
failureThreshold: 24
livenessProbe:
httpGet:
path: /livez
port: http
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: /readyz
port: http
periodSeconds: 5
timeoutSeconds: 1
failureThreshold: 2
successThreshold: 1
The startup allowance is approximately 24 × 5 = 120 seconds, following the sizing method in the Kubernetes configuration task. A hypothetical 80-second initialization would fit that allowance; this is a design example, not an observed startup measurement. If the container cannot initialize within the allowance, startup failures can cause a restart. Liveness and readiness wait for startup success before doing their own jobs.
Once startup succeeds, two failed readiness checks withdraw ordinary Service traffic without requesting a container restart. Three failed liveness checks request a restart under the applicable container restart behavior. Do not promise an exact ten- or thirty-second reaction: probe scheduling, timeout duration, and propagation through the traffic path affect the observed transition. Verify those timings on the supported cluster version.
Measure startup in the environments the service actually uses. Include cold filesystem caches, resource limits, configuration loading, and required initialization. Separate a slow but progressing startup from a startup that cannot complete because configuration is invalid.
Choose the startup allowance from those observations and the operational cost of waiting. An allowance that is too short can repeatedly interrupt legitimate initialization. An allowance that is too long can delay feedback about a broken deployment. There is no useful universal number without the workload's startup distribution and recovery requirements.
Keep schema migration ownership explicit. Running an incompatible or long migration in every replica's startup path introduces coordination questions that probe timing cannot solve. Use the database migration guide to assess that boundary before adjusting the startup threshold to conceal it.
Record how the service reports progress without leaking configuration. If initialization stalls, operators should be able to distinguish a dependency timeout from a process deadlock using sanitized telemetry. A probe result alone should not carry that entire diagnostic burden.
Exercise transitions instead of checking one happy response
Create an isolated failure exercise with known expected actions. For the endpoint contracts above, use three separate faults:
- Block only the recommendation provider. Document reads should succeed without recommendations, readiness should stay true, and restart count should not increase.
- Block the required database. Readiness should fail because document reads cannot succeed. Liveness should remain true while the application is responsive and capable of reconnecting. Restarting every replica would add startup work without restoring the database.
- Stop progress inside one replica. Liveness should fail if its endpoint actually observes that loss of progress. After the restart, startup must succeed before the replica becomes ready again.
Measure each result from both the Pod state and a test client using the Service. Readiness withdrawal does not instantly cancel already accepted requests or prove that every external load balancer has updated its view.
Include recovery. Restore the database and verify that the application can become useful without unnecessary manual intervention. Confirm that connection recovery does not report readiness before the service can satisfy the operation readiness is meant to protect.
Test slow responses as well as explicit failures. A probe that completes only after an unbounded dependency wait can delay the platform's decision. Test alternating success and failure to reveal excessive state flapping, then evaluate thresholds against the harm of delayed withdrawal and repeated reinstatement.
Inspect the delivered configuration for the actual workload. An endpoint returning success in a developer terminal does not demonstrate that the platform is polling it, interpreting its result correctly, or applying the intended recovery action.
Connect probe behavior to rollout evidence
During a deployment, compare readiness transitions with real request success and the age of newly started replicas. A replica can pass its probe while a user journey still fails because the probe covers a narrower operation. Preserve both observations instead of promoting probe success into a release verdict.
Keep shutdown behavior consistent with the readiness contract. The graceful shutdown guide covers draining accepted work; probe design determines how the platform sees the replica while that lifecycle changes.
Retain the previous reviewed probe configuration before rollout. If the database interruption test causes liveness restarts, repair that signal-to-action mapping before deployment. If the optional provider test withdraws every replica, decide whether the application has lost its promised degraded mode or the readiness endpoint is testing the wrong condition.
Was this guide useful?
Your rating helps us prioritize clearer, more practical technical content.
Review diffs, run checks, and prepare the release in Arezgit.
Keep Git review, security scanning, API checks, database inspection, and release preparation together in one local desktop application.
Explore Arezgit