Liveness, Readiness, and Startup Probes in Kubernetes: A Deep Dive into Container Health
Learn how Kubernetes decides whether your containers are alive, ready for traffic, or still starting up, how each probe behaves and fails, how to tune them safely, and how to avoid the classic mistakes that turn health checks into outages.
Imagine a hospital ward with a nurse who walks the rounds. Every few minutes she checks each patient with three different questions. First: is this patient still alive, or do we need to call the emergency team? Second: is this patient well enough to receive visitors right now? Third: has this new patient finished waking up from surgery, so we can begin the regular checks? Kubernetes has exactly such a nurse on every machine, called the kubelet, and the three questions are the liveness, readiness, and startup probes. Getting these three checks right is one of the most valuable skills for running reliable applications, and getting them wrong is one of the most common causes of mysterious outages.
1Why Health Probes Exist
A running program is not always a working program.
When you start an application in a container, the simplest thing Kubernetes can observe is whether the main process is running. If the process exits, Kubernetes knows something is wrong and can restart it. But many failures are quieter. A web server may be running yet stuck in a deadlock, unable to answer any request. A database client may have lost its connection and be waiting forever. A new application may be running but still loading data into memory and not yet able to serve anyone. From the outside, the process looks fine, while users see errors or endless waiting.
Probes are Kubernetes’ answer to this gap. A probe is a small, repeated check that the kubelet performs against a container to learn something the process status alone cannot tell. By asking the container itself, through a web request, a network connection, or a small command, Kubernetes can tell whether the application is truly healthy and can act automatically: restart it, stop sending it traffic, or wait patiently for it to finish starting.
Think of a shop assistant standing behind the counter. Seeing the person standing there tells you they are present, but not whether they are awake, able to serve, or busy in the back room. Asking “Can I help you?” and getting a sensible answer tells you far more. A probe is that question, asked automatically and repeatedly.
What can go wrong without probes
Without probes, Kubernetes assumes that a running container is healthy and ready the moment it starts. Traffic is sent to pods that are still loading. Stuck pods stay in service forever, quietly failing requests. Rolling updates proceed to replace healthy old pods with new pods that cannot yet answer, causing an outage during what should have been a safe release.
This guide assumes you know what a pod and a container are, but every new term is explained when it first appears. The focus is on understanding why each probe exists and how they interact, because that understanding matters more than memorising settings.
2How Kubernetes Sees Container Health by Default
Without probes, “running” means “healthy” and “started” means “ready”.
By default, Kubernetes trusts the container’s main process. If the process is alive, the container is considered running. If the process exits, the kubelet restarts it according to the pod’s restart policy. That is the entire health model when no probes are defined. It handles crashes well, since a crashed process is gone, but it is blind to every failure in which the process stays alive.
The same default applies to readiness. A container with no readiness probe is treated as ready as soon as it starts. The pod is added to the Service’s list of endpoints immediately, and traffic begins to flow, whether or not the application inside has finished initialising. For a small program that starts in milliseconds, this is harmless. For a large application that needs half a minute to warm up, it means the first users of every new pod receive errors.
| Situation | What Kubernetes Sees Without Probes | What Really Happens |
|---|---|---|
| Process crashes and exits | Container stopped, will be restarted | Handled correctly |
| Process is running but deadlocked | Container running, all fine | Requests hang or fail, and nobody restarts it |
| Application is still loading data | Container running and ready | Traffic arrives and fails until loading finishes |
| Application lost its database connection | Container running and ready | Pod keeps receiving requests it cannot answer |
| Application is overloaded and slow | Container running and ready | More traffic keeps arriving and makes it worse |
flowchart TD
A[Container process starts] --> B[Kubernetes marks it running and ready]
B --> C[Service starts sending traffic]
C --> D{Is the application really able to serve?}
D -->|Yes| E[Users are served]
D -->|No, still loading or stuck| F[Users see errors]
F --> G[Nothing detects the problem]
A green “Running” status on a pod does not mean the application is working. It only means the process exists. Only probes let Kubernetes look inside the application’s behaviour.
3The Three Probes at a Glance
Each probe asks a different question and triggers a different action.
The three probes are easy to confuse because they use the same mechanisms and the same settings. What differs is the question each asks and, crucially, what Kubernetes does when the answer is no. Keeping this distinction clear removes most of the confusion around probes.
Liveness
Question: is this container stuck or broken beyond recovery? Action on failure: the container is killed and restarted.
Readiness
Question: can this container handle traffic right now? Action on failure: the pod is removed from Service endpoints, with no restart.
Startup
Question: has this container finished starting up? Action while running: liveness and readiness checks are held back. Action on failure: the container is restarted.
| Aspect | Liveness | Readiness | Startup |
|---|---|---|---|
| Main question | Should this container be restarted? | Should this pod receive traffic? | Is start-up complete? |
| Action on failure | Restart the container | Remove from Service endpoints | Restart the container after the allowed attempts |
| Runs how long | Whole life of the container, after start-up completes | Whole life of the container, after start-up completes | Only until it succeeds once |
| Recovers by itself | No, a restart is the recovery | Yes, pod returns when checks pass | Not applicable, success ends its job |
| Best for | Deadlocks and hung processes | Warm-up, overload, temporary trouble | Slow-starting applications |
| Risk if badly set | Restart storms | All pods removed from service at once | Restart loops during a long start-up |
Back at the hospital: the liveness check asks whether the patient needs the emergency team. The readiness check asks whether the patient can receive visitors now. The startup check asks whether a new arrival has woken up enough to begin the ordinary rounds. Calling the emergency team for a patient who simply cannot have visitors right now would be a costly mistake, and that is exactly the mistake many teams make with probes.
4The Liveness Probe in Depth
The last line of defence against a container that cannot recover on its own.
A liveness probe tells Kubernetes whether a container is still functioning at a basic level. If the probe fails several times in a row, the kubelet concludes that the container is stuck in a state it will never leave by itself, kills it, and starts a new one according to the pod’s restart policy. The whole point is to turn “stuck forever” into “restarted and hopefully healthy.”
Liveness probes are meant for one particular kind of failure: the process is running but cannot make progress. Classic examples are a deadlock between threads, an infinite loop, or an internal component that has crashed while the main process survives. A restart fixes these problems because it resets the program to a clean state. A restart does not fix problems that live outside the container, such as a database outage, and this distinction is the key to using liveness safely.
sequenceDiagram
participant K as Kubelet
participant C as Container
loop Every period
K->>C: Liveness check
alt Healthy
C-->>K: Success
else Stuck
C-->>K: Failure or timeout
K->>K: Count consecutive failures
end
end
K->>C: Failure threshold reached, stop container
K->>C: Start a new container instance
Note over K,C: Restart delay grows if the container keeps failing
What liveness is good at
- Recovering from deadlocks and hung processes automatically
- Clearing internal corruption by starting from clean state
- Reducing the need for people to restart applications by hand
- Turning silent failure into a visible restart count
What liveness cannot or should not do
- Fix problems in dependencies such as databases
- Handle temporary overload gracefully
- Wait for a slow start-up unless combined with a startup probe
- Replace proper error handling inside the application
A liveness check is like a smoke alarm that rings the fire brigade only when the kitchen is truly on fire. It should not ring because the toast is slightly dark, and it should not ring because the neighbours’ power is out. Its job is narrow and serious.
If a container keeps failing and restarting, Kubernetes waits longer and longer between attempts, up to a few minutes. This is the familiar crash loop state. Repeated liveness restarts show up as a rising restart count on the pod.
5The Readiness Probe in Depth
The gate that decides whether a pod may receive traffic.
A readiness probe tells Kubernetes whether a container is ready to serve requests at this moment. While the probe succeeds, the pod is listed among the endpoints of every Service that selects it, and traffic flows to it. When the probe fails, the pod is removed from those lists. The container keeps running and is not restarted; it is simply left alone until it reports ready again.
This makes readiness the right tool for anything temporary. A new pod that is still warming its caches is not ready yet. A pod that is busy with an overload may report not ready for a short while to shed load. A pod that has lost a needed connection may become ready again once it reconnects. In all of these cases, restarting would be unnecessary and even harmful, but withholding traffic is exactly right.
stateDiagram-v2
[*] --> NotReady: container starts
NotReady --> Ready: readiness probe succeeds
Ready --> NotReady: readiness probe fails
NotReady --> Ready: probe succeeds again
Ready --> [*]: pod terminating, removed from endpoints
Service endpoints
Only ready pods appear in the list of addresses behind a Service, so traffic avoids pods that are not ready.
Rolling updates
A rollout counts a new pod as available only when it is ready, so a broken new version stalls the rollout instead of replacing healthy pods.
Pod status
The pod’s ready condition follows its containers. A pod is ready only when all of its containers are ready.
Autoscaling and budgets
Autoscalers and disruption budgets treat not-ready pods specially, so readiness quietly influences scaling and maintenance behaviour.
A restaurant’s “open” sign is a readiness check. When the kitchen is still preparing for service, the sign says closed, and customers are not sent to a table. Nobody fires the chef or rebuilds the restaurant. The sign flips to open when things are truly ready.
The readiness probe keeps running for the whole life of the container, not just at start-up. A pod can become not ready in the middle of its life and later become ready again, which is a powerful way to handle temporary trouble.
6The Startup Probe in Depth
A patient guardian for applications that take a long time to start.
The startup probe was added to solve a specific problem. Some applications need a long and unpredictable time to start, perhaps because they load large data sets, run migrations, or initialise heavy frameworks. A liveness probe that is strict enough to catch deadlocks quickly will kill such an application while it is still starting, because it cannot answer yet. Loosening the liveness probe to allow for slow starts makes it slow to detect real deadlocks later. It is a painful trade-off.
The startup probe resolves the trade-off by separating the two phases. While the startup probe is running, the liveness and readiness probes are switched off. Once the startup probe succeeds, it stops for good, and the liveness and readiness probes take over with their normal, stricter settings. If the startup probe never succeeds within its allowed budget, the container is killed and restarted.
sequenceDiagram
participant K as Kubelet
participant C as Container
K->>C: Startup check
C-->>K: Not yet
K->>C: Startup check
C-->>K: Not yet
Note over K,C: Liveness and readiness are paused
K->>C: Startup check
C-->>K: Success
Note over K,C: Startup probe stops, liveness and readiness begin
loop From now on
K->>C: Liveness and readiness checks
end
The start-up budget
The maximum time an application is given to start is the failure threshold multiplied by the period. With a period of ten seconds and a failure threshold of thirty, the application has up to five minutes to become healthy. If it starts in twenty seconds, the startup probe succeeds at the next check and the liveness probe begins at once, so a generous budget costs nothing when start-up is quick.
A patient waking from surgery is watched patiently by the recovery nurse, who does not sound the alarm because the patient has not yet sat up. Only when the patient is fully awake do the regular ward checks begin. The recovery nurse is the startup probe.
Using a huge initial delay on the liveness probe instead of a startup probe. That delay is always paid, even when the application starts quickly, and it leaves a long blind period after every restart. A startup probe adapts to the real start-up time.
7How the Three Probes Work Together
A container’s life is a sequence of phases, and each probe owns one of them.
When all three probes are defined, they form a sequence. The startup probe guards the first phase, during which nothing else runs. When it succeeds, the liveness and readiness probes begin in parallel and keep running for the remainder of the container’s life. Liveness watches for a permanently stuck container, while readiness watches for a temporarily unfit one.
Container starts
The process begins. The pod is not ready, and traffic does not flow to it yet, if a readiness or startup probe is defined.
Startup probe runs
The kubelet checks repeatedly whether start-up has finished. Liveness and readiness probes wait.
Startup succeeds
The startup probe ends. The liveness and readiness probes now begin their regular schedules.
Readiness passes and traffic begins
Once the readiness probe succeeds, the pod joins the Service endpoints and starts receiving requests.
Normal life
Readiness may flip on and off as conditions change. Liveness stays quietly passing, unless the container becomes truly stuck.
Failure or shutdown
A stuck container is restarted after liveness failures, and the cycle begins again. A terminating pod is removed from endpoints regardless of its probes.
flowchart TD
S[Container starts] --> SP{Startup probe defined?}
SP -->|Yes| W[Wait for startup probe to succeed]
SP -->|No| LR
W -->|Fails beyond budget| R[Container restarted]
W -->|Succeeds| LR[Liveness and readiness start]
LR --> L{Liveness failing repeatedly?}
L -->|Yes| R
L -->|No| RD{Readiness passing?}
RD -->|Yes| T[Pod receives traffic]
RD -->|No| N[Pod removed from endpoints, keeps running]
N --> RD
For most services, define a startup probe with a generous budget, a readiness probe that reflects real ability to serve, and a simple, forgiving liveness probe that only detects a truly stuck process.
8How a Probe Checks: HTTP, TCP, Command, and gRPC
Four mechanisms, each with its own strengths and blind spots.
Every probe, whichever of the three kinds it is, must perform its check in one of four ways. The kubelet runs the check from the node where the pod lives. The choice of mechanism decides what the probe can actually detect, how much it costs, and what can go wrong with it.
| Mechanism | How It Checks | Counts as Success When | Best For | Watch Out For |
|---|---|---|---|---|
| HTTP request | Sends a web request to a path and port on the pod | The response status is in the success range, roughly two hundred to three hundred ninety-nine | Web services and APIs with a health endpoint | A health path that does too much work or requires login |
| TCP connection | Tries to open a network connection to a port | The connection is accepted | Non-web servers such as databases and message brokers | Proves only that something is listening, not that it works |
| Command | Runs a command inside the container | The command exits with a zero status | Applications with a command-line health tool or file-based signals | Costs a new process each time and needs the tool inside the image |
| gRPC call | Calls a standard gRPC health service on a port | The service reports that it is serving | Services that already speak gRPC | Requires the application to implement the standard health protocol |
flowchart LR
K[Kubelet on the node] -->|web request to pod address| H[HTTP probe]
K -->|open connection| T[TCP probe]
K -->|run command inside container| E[Command probe]
K -->|gRPC health call| G[gRPC probe]
H --> APP[Application in the container]
T --> APP
E --> APP
G --> APP
To check whether a shop is working, you can ask a question through the door, which is like an HTTP probe. You can knock and see if anyone opens, which is a TCP probe. You can send someone inside to look, which is a command probe. Or you can phone the shop’s dedicated health line, which is gRPC. Knocking is cheap but tells you little, and sending someone inside tells you a lot but costs more.
HTTP for most web applications
A small, dedicated health path that returns quickly and without login is the most common and informative choice for services that already speak web protocols.
TCP for simple servers
When there is no health path, opening the port at least proves the server has started listening. It is a reasonable check for readiness, though weak for liveness because a hung server may still accept connections.
Command for special cases
Useful when the application offers a check tool, or writes a file that shows recent activity. Keep the command light, because it runs a new process on every check.
gRPC when you already use it
Services built on gRPC can implement the standard health protocol and be checked natively, without adding a separate web endpoint just for probes.
9Timing Settings and What They Really Do
Five numbers decide how quickly a probe reacts and how forgiving it is.
All three probes share a small set of timing settings. Learning what each one controls, and how they combine, lets you predict exactly how long Kubernetes takes to notice a problem. Most probe incidents come from settings that were copied without understanding.
| Setting | Default | What It Controls | Notes |
|---|---|---|---|
| Initial delay | Zero seconds | How long to wait after the container starts before the first check | A startup probe is usually a better solution than a long delay |
| Period | Ten seconds | How often the check is repeated | The minimum is one second |
| Timeout | One second | How long to wait for an answer before counting a failure | Too short a timeout causes false failures under load |
| Success threshold | One | How many consecutive successes turn a failing probe back to passing | Must be one for liveness and startup probes |
| Failure threshold | Three | How many consecutive failures mark the probe as failed | Multiplied by the period, it sets the reaction time |
A worked example
Consider a liveness probe with a period of ten seconds, a timeout of two seconds, and a failure threshold of three. If the application becomes stuck, the first failing check may come up to ten seconds later. Three consecutive failures are needed, each taking up to two seconds to time out, so the container is restarted roughly thirty to forty seconds after the application gets stuck. If you instead used a period of five seconds and a threshold of two, the reaction would take about ten to fifteen seconds, but the probe would be far more sensitive to short glitches.
sequenceDiagram
participant A as Application
participant K as Kubelet
Note over A: Application becomes stuck
K->>A: Check 1, times out
Note over K: Failure count 1
K->>A: Check 2, times out
Note over K: Failure count 2
K->>A: Check 3, times out
Note over K: Failure count 3, threshold reached
K->>A: Restart container
A night watchman who rings the alarm after one missed check would wake the whole street for every cat. A watchman who waits for many missed checks lets a burglar escape. The period and thresholds are how you decide how nervous the watchman should be.
The default timeout is only one second. Under heavy load, or during a brief pause such as memory cleanup, an application may take longer to answer even though it is perfectly healthy. Several such slow answers in a row cause a false failure. Set the timeout to a realistic value for your application under load.
For liveness and startup probes, you can also set a shorter grace period for the kill that follows a failed probe. This lets a stuck container be stopped quickly, without waiting for the full grace period that is meant for orderly shutdowns.
10Designing Good Health Endpoints
A probe is only as good as the check behind it.
The probe settings tell Kubernetes when and how to ask. The health endpoint decides what the answer means. A poorly designed endpoint makes even perfect settings useless or dangerous. The most important principle is that liveness and readiness answer different questions, so they should usually be different endpoints with different logic.
| Aspect | Liveness Endpoint | Readiness Endpoint |
|---|---|---|
| Question answered | Is the process itself functioning and able to make progress? | Can I serve real requests right now? |
| What to check | Only internal health, such as the main loop responding | Internal health plus readiness of what is needed to serve, such as caches loaded and required connections open |
| External dependencies | Do not check them | Check only those without which you truly cannot serve, and with care |
| Cost | Extremely cheap, returns immediately | Cheap, with any dependency checks cached briefly |
| Failure meaning | Restarting will probably help | Waiting or traffic redirection will help |
| Typical path names | Something like a live or health path | Something like a ready path |
Keep it fast
The endpoint should answer in milliseconds. A slow health check adds load and risks timeouts exactly when the application is under stress.
Keep it honest
Return failure only when something is really wrong, and success only when it is really fine. A check that always says yes is decoration.
Keep it simple
Avoid complicated logic, authentication, and heavy queries. Simple checks fail rarely and are easy to understand.
Keep it separate
Use a distinct endpoint for each probe so that you can tune their meaning independently as the application evolves.
Asking a shop assistant “are you awake?” is a quick liveness question. Asking “can you serve me right now, with the till working and stock available?” is a readiness question. Combining them means you would send the assistant home whenever the till is temporarily out of paper, which helps nobody.
Many projects follow the convention used by Kubernetes components themselves, with separate live and ready style paths. Whatever names you choose, keep them consistent across your services so that everyone knows where to look.
11Dependencies and Cascading Failures
The most dangerous mistake in probe design is checking things outside the container.
It is tempting to make a health check verify that the database is reachable, the cache is up, and the other services respond. After all, if the database is down, the application is not really healthy. But what should Kubernetes do about it? If the liveness probe fails because the database is down, Kubernetes restarts the application container. The restart does nothing to fix the database. The restarted application fails the same check and is restarted again. Now every pod of the application is in a restart loop, the application is completely unavailable, and the database, once it recovers, is met by a thundering herd of freshly started pods all connecting at once.
sequenceDiagram
participant D as Shared database
participant P as Application pods
participant K as Kubelet
D->>D: Becomes unavailable
P->>K: Liveness checks fail, dependency down
K->>P: Restart all pods
P->>D: Reconnect, still down
K->>P: Restart again
Note over P: Application fully down, restart loops
D->>D: Recovers
P->>D: All pods reconnect at once
Note over D: Surge of connections may overload it again
Readiness and dependencies
Readiness is a better place to consider dependencies, because its failure action, withholding traffic, is gentle and reversible. If a pod cannot reach a database it truly needs, it is reasonable to stop sending it requests until the connection returns. But even here, care is needed. If every pod depends on the same shared service, and that service has a brief outage, every pod becomes not ready at once. The Service then has no endpoints at all, and a partial degradation becomes a total outage, even for requests that did not need the failing service.
Checking a dependency in readiness
- Stops routing traffic to pods that cannot do their job
- Pods recover automatically when the dependency returns
- Makes a single pod’s local connection problem visible
The risks
- A shared dependency failure removes every pod at once
- Requests that did not need the dependency are refused too
- Slow dependency checks add delay and load
- Flapping dependency makes pods bounce in and out of service
If the supplier of tomatoes is late, closing every branch of a restaurant chain helps nobody, and rebuilding the kitchens will not bring the tomatoes any faster. A better plan is to keep serving the dishes that do not need tomatoes, and to be honest on the menu about what is unavailable.
Never make a liveness probe depend on anything outside the container. If a restart cannot fix the problem, the liveness probe must not react to it. For readiness, include only dependencies without which the pod truly cannot serve, and prefer graceful degradation inside the application over marking everything unready.
12Slow Starters and Start-Up Budgets
Giving heavy applications the time they need, without slowing everything else.
Many real applications take a long time to start. Large Java applications, applications that load machine learning models, and legacy systems that run migrations at boot can all take minutes. If probes are not designed with this in mind, Kubernetes will kill the application before it finishes starting, and the application will be stuck in a loop of starting and being killed.
Measure the real start-up time
Observe how long the application takes to become healthy on a busy node, not only on an idle laptop. Take the slowest realistic case, not the average.
Add a margin
Multiply the slowest observed time by a comfortable factor, for example two, to cover slow disks, busy networks, and image pulls.
Convert to threshold and period
Choose a period and compute the failure threshold so that threshold times period covers the budget. A short period makes success detected quickly.
Keep liveness strict
With start-up protected, the liveness probe can stay tight and detect real deadlocks quickly, without allowances for slow starts.
Revisit when the application changes
A new dependency, larger data set, or extra migration can slow start-up. Review the budget whenever start-up behaviour changes.
| Approach | How It Works | Weakness |
|---|---|---|
| Long initial delay on liveness | Waits a fixed time before the first check | Always paid, even when start-up is fast, and leaves a long blind spot after each restart |
| Very high failure threshold on liveness | Tolerates many failures | Makes real deadlocks slow to detect for the whole life of the container |
| Startup probe with generous budget | Waits only as long as needed, then hands over to a strict liveness probe | One more probe to define, but the best trade-off |
Also reduce start-up time where you can: smaller images, lazy loading of large data, and moving migrations out of the start-up path. A faster start-up helps probes, rollouts, autoscaling, and recovery all at once.
13Readiness in Rolling Updates, Services, and Autoscaling
Readiness quietly steers several other Kubernetes features.
Readiness does much more than open and close the door to traffic. Several higher-level features use it as their definition of a pod being usable. Understanding these links explains why a poor readiness probe can cause problems in places that seem unrelated to health checks.
Rolling updates
A new pod counts as available only when ready. The rollout moves on only after that, so a good readiness probe is what prevents a bad release from replacing healthy pods.
Service endpoints
Ready pods are in the endpoint list and receive traffic. Not-ready pods are left out, unless the Service is told to publish them.
Horizontal autoscaling
The autoscaler handles not-ready and newly started pods carefully, because their early usage numbers are not representative. Slow readiness slows the autoscaler’s confidence.
Disruption budgets
A budget counts only healthy, ready pods when deciding how many may be taken down for maintenance.
Minimum ready time
A Deployment can require a pod to stay ready for a number of seconds before counting it as available, adding a safety margin against pods that pass and then fail.
sequenceDiagram
participant D as Deployment
participant N as New pod
participant O as Old pod
participant S as Service
D->>N: Create new pod
N->>N: Start, readiness not yet passing
Note over D,N: Rollout waits
N->>S: Readiness passes, joins endpoints
D->>O: Now safe to remove an old pod
O->>S: Leaves endpoints
Note over D: Repeat until all pods are replaced
When replacing waiters in a busy restaurant, the manager only sends an old waiter home after the new one has proved they can carry plates without dropping them. The readiness probe is that proof. Without it, the manager would send everyone home the moment the replacements walked in.
If a readiness probe is missing or always succeeds, a rollout proceeds even when the new version is broken, and an outage results. A working readiness probe is the single most important safety net of rolling updates.
14Readiness and Graceful Shutdown
Stopping a pod politely takes cooperation between probes, the network, and the application.
When a pod is told to stop, it is marked as terminating and removed from Service endpoints, and the container receives a termination signal. But removal from endpoints and the shutdown signal happen at about the same time, and it takes a moment for load balancers and proxies across the cluster to learn that the pod is gone. During that moment, new requests may still arrive at a pod that has begun shutting down.
sequenceDiagram
participant K as Kubelet and controllers
participant E as Endpoint lists
participant L as Load balancers and proxies
participant P as Terminating pod
K->>P: Mark terminating
par Endpoint removal
K->>E: Remove pod
E->>L: Propagate change
and Shutdown begins
P->>P: Optional pre-stop delay
P->>P: Receive termination signal
end
L-->>P: Late requests may still arrive
P->>P: Finish in-flight requests
P->>K: Exit within grace period
Add a short pre-stop delay
A brief pause before the shutdown signal gives the rest of the network time to stop sending traffic, which removes most connection errors during rollouts.
Handle the termination signal properly
The application should stop accepting new connections, finish current requests, and then exit, rather than dying instantly.
Report not ready when draining
Some applications begin failing their own readiness check as soon as shutdown starts, which helps proxies that use the check directly to stop routing sooner.
Match the grace period to reality
The total grace period must exceed the pre-stop delay plus the longest request, otherwise in-flight work is cut off.
A liveness probe should not fire during graceful shutdown. Keep the shutdown fast enough, and the probe forgiving enough, that a slow but orderly drain is never mistaken for a stuck process.
15Common Failure Modes: Crash Loops, Flapping, and Restart Storms
Probe problems tend to appear in a few recognisable patterns.
Restart loop during start-up
The liveness probe starts checking before the application is ready, fails, and kills it repeatedly. The fix is a startup probe or a more patient budget.
Flapping readiness
The probe alternates between passing and failing, so pods bounce in and out of service. It is often caused by tight timeouts or a check that depends on something unstable.
Restart storm under load
Heavy load makes health checks slow, liveness fails, pods restart, remaining pods take even more load, and the failure spreads across the whole application.
Total unreadiness
Every pod fails readiness at once, usually because of a shared dependency check, and the Service has no endpoints at all.
Silent false success
A check that always passes, such as one that only confirms the process exists, lets broken pods stay in service and hides real problems.
flowchart TD
A[Traffic spike] --> B[Application slows down]
B --> C[Health checks exceed timeout]
C --> D[Liveness fails repeatedly]
D --> E[Kubelet restarts pods]
E --> F[Fewer healthy pods]
F --> G[Remaining pods get even more load]
G --> B
Imagine a restaurant so busy that waiters are slow to answer the manager’s “are you all right?” calls. If the manager sends slow waiters home as punishment, the remaining waiters become even more overloaded, and soon nobody is left. Slowness under load is not the same as being stuck, and the response to it must be gentler.
A liveness probe should distinguish between a container that is slow and one that is stuck. Use generous timeouts and thresholds for liveness, and let readiness, which is reversible, handle overload by temporarily withholding traffic.
16Tuning Probes for Real-World Conditions
The same settings behave differently on a quiet laptop and a busy production node.
Probes tuned on an idle test cluster often fail in production. Real nodes are shared with many other pods, disks are slower, networks are busier, and applications pause for memory cleanup. Tuning probes means choosing values that hold up under these conditions while still reacting quickly enough to real trouble.
| Probe | Period | Timeout | Failure Threshold | Reasoning |
|---|---|---|---|---|
| Startup | Short, for example five to ten seconds | A few seconds | High enough to cover the slowest start-up | Notices success quickly, allows a long total budget |
| Readiness | Short, for example five to ten seconds | Moderate, a few seconds | Low to moderate, two or three | Reacts fairly quickly, because its action is reversible |
| Liveness | Longer, for example ten to twenty seconds | Generous, several seconds | Moderate to high, three to five | Reacts slowly and deliberately, because its action is disruptive |
Start with sensible defaults
Begin with the recipe above and the application’s measured behaviour, not with values copied from another team’s service.
Test under load
Run load tests and watch whether probes fail during heavy traffic, garbage collection pauses, or node pressure.
Simulate real failures
Cause a deadlock, a slow dependency, and a slow start on purpose. Check that each probe reacts as intended, and only as intended.
Adjust and record the reasons
Tune values, and write down why they were chosen so that future changes do not undo the reasoning by accident.
Make readiness quick to fail and slow to forgive, or quick both ways, since it is reversible. Make liveness slow to fail, since it is destructive. The consequences of each failure decide how sensitive it should be.
17Performance and Scale Considerations
Probes are cheap individually, but they add up across a large cluster.
Every probe is a small piece of work performed on a schedule. With a few pods this is invisible. In a cluster with thousands of pods, each with two or three probes running every few seconds, the total volume of checks becomes significant, both for the kubelets that run them and for the applications that answer them.
Advantages
- Checks run on the node, so no central component is loaded
- Each kubelet handles only the probes of its own pods
- Cheap checks add almost no overhead
- Results feed automation without any extra tooling
Disadvantages / Trade-offs
- Command probes start a new process on every check
- Heavy health endpoints add load to already busy applications
- Very short periods multiply the number of checks
- Many failing probes create a flood of events and restarts
Prefer light mechanisms
HTTP and gRPC checks to a lightweight handler are usually cheaper than launching a command inside the container each time.
Do not probe too often
A period of a few seconds is usually plenty. Extremely short periods add load without meaningfully faster recovery.
Cache expensive checks
If a readiness check must consult something costly, let the application cache the result for a short time and answer probes from the cache.
Reserve capacity for probe handling
Make sure a busy application can still answer its health endpoint, for example by using a separate thread or port so that saturation does not block the checks.
18Security Considerations
Health endpoints are small doors into your application, and they should be treated with care.
Health checks exist for automation, but the endpoints they call are usually reachable by other workloads inside the cluster network. A careless health endpoint can leak information or provide an easy way to overload the application. Security thinking for probes is mostly about limiting what they reveal and what they can do.
Reveal as little as possible
A health endpoint should return a simple status, not version numbers, configuration, dependency names, or error details. Those are useful to an attacker exploring your system.
Keep secrets out of probe definitions
Headers or arguments in a probe definition are visible to anyone who can read the pod specification. Do not place passwords or tokens in them.
Do not require authentication that the kubelet cannot provide
A health path behind a login will fail every check. Instead, keep the path simple and separate from protected routes, or use a dedicated port not exposed outside the cluster.
Limit who can reach the endpoint
Use network policies so that only the node agent and necessary internal tools can reach health paths, and never expose them through a public ingress.
Remember command probes run with the container’s privileges
A command probe executes inside the container with its permissions, so keep the command minimal and avoid tools that could be abused if the image is compromised.
Guard against probe abuse
A health endpoint that does heavy work can be used to overload the application by calling it repeatedly. Keep it light, and it stays harmless.
A common accident is exposing the whole application, including its health and diagnostic paths, through a public route. Route only the paths meant for users, and keep health endpoints internal.
19Troubleshooting Probes
The cluster records why a probe failed, if you know where to look.
When a pod restarts unexpectedly or never becomes ready, probes are a prime suspect. Fortunately, Kubernetes leaves clear evidence. Each failed probe produces an event on the pod that names the probe type and the reason, such as an unexpected status code, a connection refused, or a timeout. Reading these events is the fastest way to understand what is happening.
Describe the pod and read the events
Look for messages saying that a liveness, readiness, or startup probe failed, and read the stated reason. It usually points straight at the cause.
Check restart counts and last state
A rising restart count with a last state showing termination after a failed probe confirms that liveness or startup is killing the container.
Call the endpoint yourself
From another pod, or from inside the container, request the same path and port that the probe uses. Compare the answer and its timing with what the probe expects.
Verify the definition
Check the path, port, scheme, and command. A wrong port number or a path that does not exist is a very common cause, and it fails every time.
Compare the timing with reality
Check whether the application really starts and answers within the timeout and threshold you configured, especially on a loaded node.
Read the application logs
Logs from before the restart, and from the health handler itself, often show what the application was doing when the checks failed.
| Symptom | Likely Cause | What To Do |
|---|---|---|
| Restarts shortly after every start | Liveness begins before the application is ready | Add a startup probe or lengthen the start-up budget |
| Connection refused in probe events | Wrong port, or application not yet listening | Check the port, and use a startup probe for slow starts |
| Unexpected status code in probe events | Endpoint returns an error, redirect, or requires login | Fix the endpoint or the path, and keep it simple and open |
| Timeouts under load only | Timeout too short for a busy application | Increase the timeout, lighten the endpoint, use a separate thread or port |
| Pod stays not ready for a long time | Readiness never passes because of a wrong check or missing dependency | Verify the check and the dependency, and test the endpoint manually |
| All pods not ready at once | Shared dependency in readiness check | Remove or soften the dependency check |
| Command probe fails inexplicably | Tool missing from the image, or command too slow | Confirm the tool exists, and make the command light |
| Rollout stuck | New pods never become ready | Investigate readiness of the new version, and roll back if needed |
If you cannot tell whether a probe or the application is at fault, temporarily relax the probe in a test environment and observe the application directly. A container that runs fine without the probe and fails with it tells you the probe design is the problem.
20Monitoring and Metrics for Probes
Health checks should be watched, not just trusted.
Probes work quietly in the background, which is exactly why problems with them can go unnoticed for a long time. A pod that restarts once a day because of a slightly too strict liveness probe may never trigger an alarm, yet it steadily degrades user experience. Good monitoring turns probe behaviour into visible numbers and alerts.
Container restart counts
The most important signal. Any steady growth in restarts deserves investigation, since it often means liveness is killing containers.
Ready versus desired pods
A gap between the desired and the ready number of pods shows that readiness is failing somewhere, or that a rollout is stuck.
Probe results per type
The kubelet exposes counters of probe results by type. Rising failure counts reveal flaky or too strict checks before restarts pile up.
Service endpoint counts
The number of endpoints behind each Service should track the number of ready pods. A drop to zero means users are getting errors.
Time to ready after start
Track how long new pods take to become ready. A creeping increase warns that start-up budgets may soon be too small.
Health endpoint latency
Measure how long the health handler takes to answer. If it approaches the timeout, false failures are coming.
flowchart TD
M[Monitoring system] --> A1[Alert: restarts rising for a workload]
M --> A2[Alert: ready pods below desired for several minutes]
M --> A3[Alert: probe failures rising]
M --> A4[Alert: Service with zero endpoints]
M --> A5[Alert: rollout not progressing]
A1 --> R[Investigate probes and application]
A2 --> R
A3 --> R
A4 --> R
A5 --> R
A handful of restarts per week seems harmless, but it often points to a real defect or a badly tuned probe. Treat unexplained restarts as bugs to be understood, not as normal background noise.
21Design Patterns for Probes
Reliable arrangements used across many production services.
Pattern: Startup, readiness, and liveness together
Define all three. The startup probe protects slow starts, readiness controls traffic, and liveness detects real deadlocks with a strict but forgiving configuration.
Pattern: Separate endpoints for separate questions
Provide distinct live, ready, and start paths so each can evolve independently, and no single change accidentally alters the meaning of all three.
Pattern: Dedicated health port
Serve health endpoints on a separate port and thread pool, so that a saturated application port cannot block health checks, and health paths are never exposed to users.
Pattern: Cached dependency status
Let a background task check dependencies periodically and store the result. The readiness endpoint reads the stored result, giving fast answers without hammering dependencies.
Pattern: Drain on shutdown
On the shutdown signal, switch readiness to failing, wait briefly, finish in-flight requests, and exit. Combined with a short pre-stop delay, this makes rollouts nearly invisible to users.
Pattern: Heartbeat file for workers
Background workers without a web port write a timestamp to a file as they make progress. A command probe checks that the timestamp is recent, detecting stuck workers without any network endpoint.
flowchart TD
A[Application] --> H[Health port, separate thread pool]
H --> L[Live endpoint
process alive and progressing]
H --> R[Ready endpoint
reads cached dependency status]
H --> S[Start endpoint
initialisation finished]
B[Background dependency checker] --> C[Cached status]
C --> R
22Anti-patterns to Avoid
Habits that turn health checks into a source of outages.
Problem
Making the liveness probe check a database or another external service.
Why It’s Harmful
A dependency outage triggers restarts that cannot fix it, turning a partial problem into a complete outage and a thundering herd on recovery.
Correct Approach
Keep liveness limited to the process’s own health. Put dependency awareness, carefully, in readiness or in the application’s own error handling.
Problem
Using the same endpoint and settings for liveness and readiness.
Why It’s Harmful
Temporary conditions that should only pause traffic instead restart the container, and restarts make the temporary condition worse.
Correct Approach
Use separate endpoints and different sensitivity, with liveness slower and more forgiving than readiness.
Problem
Relying on a huge initial delay instead of a startup probe.
Why It’s Harmful
The delay is always paid, leaves a long blind spot after every restart, and still fails if start-up is slower than expected.
Correct Approach
Use a startup probe with a generous budget and keep the liveness settings tight.
Problem
Leaving out the readiness probe entirely.
Why It’s Harmful
Traffic reaches pods that are still starting, and rolling updates replace healthy pods with broken ones without noticing.
Correct Approach
Define a meaningful readiness probe for every workload that receives traffic.
Problem
Keeping the default one-second timeout under real load.
Why It’s Harmful
Short pauses cause false failures, which lead to flapping readiness or unnecessary restarts.
Correct Approach
Measure real response times under load and set the timeout with a comfortable margin.
Problem
A health endpoint that always returns success.
Why It’s Harmful
Broken pods stay in service and stuck containers are never restarted, so the probe gives false comfort.
Correct Approach
Make the check reflect real ability to make progress or serve, while keeping it cheap.
Problem
Copying probe settings from another service without testing.
Why It’s Harmful
Different applications have different start-up times and response profiles, so copied values are either too strict or too lax.
Correct Approach
Measure and test each application, tune the values, and record the reasons.
23Best Practices and Common Mistakes
A short checklist for dependable health checks.
Best Practices
- Define readiness for every workload that receives traffic
- Use a startup probe for slow-starting applications
- Keep liveness simple, internal, and forgiving
- Use separate endpoints for liveness, readiness, and start-up
- Set timeouts and thresholds based on measurements under load
- Combine readiness with a graceful shutdown and a short pre-stop delay
- Monitor restarts, ready counts, and probe failures, and alert on them
Common Mistakes
- Believing that a running pod is a healthy pod
- Restarting containers because of problems that live elsewhere
- Forgetting that readiness runs for the whole life of the container
- Putting a login in front of the health path
- Ignoring the time a busy application needs to answer
- Exposing health endpoints publicly
Before relying on your probes in production, cause the failures they are meant to handle: a hung process, a slow start, a dependency outage, and a traffic spike. Watching how each probe behaves teaches more than any configuration guide.
24Real-World Scenarios
How teams use, and misuse, probes in daily operations.
A retailer surviving a database blip
A retailer’s liveness probe once checked the database. A brief database failover made every pod fail the check, and all pods restarted at once, taking the site down for minutes. The team changed liveness to check only the process itself, moved dependency awareness into readiness with cached results, and the next failover caused only a short slowdown.
A media company with a slow-starting service
A recommendation service needed four minutes to load models. Its pods were killed in a loop before they could finish. Adding a startup probe with a five-minute budget let the service start reliably, while the liveness probe stayed strict for the rest of its life.
A startup fixing failing rollouts
A startup’s releases sometimes broke production because pods were marked ready as soon as they started. After adding a readiness probe that verified the application could actually serve a test request, bad releases stalled at the first new pod, and the old pods kept serving until the team fixed the issue.
A bank taming a restart storm
During peak trading, a bank’s payment service slowed, its liveness probes timed out, and pods restarted in waves. The team raised the timeout, lightened the health handler, and moved it to a dedicated port and thread pool. Load then caused a brief loss of readiness instead of restarts, and the service recovered on its own.
An operations team finding a silent leak
A dashboard showed a workload restarting three times a day. Nobody had noticed, since users were rarely affected. Investigating showed a slow memory leak, which liveness was accidentally masking by restarting the container. The team fixed the leak instead of living with the restarts.
25Frequently Asked Questions
Liveness asks whether a container is stuck and should be restarted. Readiness asks whether a pod can serve traffic right now, and if not, removes it from Service endpoints without restarting it.
When an application takes a long or unpredictable time to start. The startup probe holds back liveness and readiness until start-up completes, so a slow start is not mistaken for a failure.
Kubernetes treats a running container as healthy and ready. Traffic reaches pods before they can serve, stuck pods are never restarted, and rolling updates cannot detect broken releases.
No. A restart cannot fix a database problem, so a liveness check on a dependency causes restart loops and turns a partial outage into a full one. Keep liveness internal to the process.
Initial delay is the wait before the first check, period is how often checks run, timeout is how long to wait for an answer, and thresholds are how many consecutive successes or failures change the state. Failure threshold times period sets the reaction time.
The failure threshold multiplied by the period. For example, thirty failures at ten-second intervals allow up to five minutes. If the application succeeds sooner, the startup probe ends immediately.
No. They run for the whole life of the container, so a pod can become not ready and ready again many times, which is useful for handling temporary trouble.
Use an HTTP check for web services, gRPC for services that speak it, a TCP check for simple servers, and a command only when nothing else fits, since commands start a process on each check.
The health check probably becomes slow under load and exceeds its timeout, so liveness fails. Increase the timeout, lighten the endpoint, and consider a dedicated health port and thread pool.
Yes, indirectly. Failing readiness when draining, together with a short pre-stop delay and proper signal handling, helps traffic move away before the container stops.
Usually because new pods never become ready. Check the readiness probe events and the new version’s behaviour, then fix the cause or roll back.
Watch container restart counts, the gap between ready and desired pods, and probe failure counters, and read probe failure events on the pods. Rising numbers usually point to a probe that is too strict or misdesigned.
26Summary and Key Takeaways
Probes give Kubernetes the ability to look inside a running application and act on what it finds. The liveness probe detects a container that is stuck beyond recovery and restarts it. The readiness probe decides whether a pod may receive traffic, and it can switch on and off throughout the container’s life without any restart. The startup probe protects slow-starting applications by holding the other two back until initialisation is complete.
The power of probes comes with responsibility. A liveness check that depends on external services can turn a small problem into a total outage. A readiness check that is missing lets broken releases replace healthy pods. Timeouts that are too tight cause restart storms under load. Good probe design means separate, cheap, honest endpoints, timing based on measurement, careful treatment of dependencies, graceful shutdown, and monitoring that shows restarts and readiness clearly. Done well, probes make an application self-healing and safe to release. Done badly, they become the cause of the outages they were meant to prevent.
Key Takeaways
- Each probe answers a different question — liveness decides whether to restart, readiness decides whether to route traffic, and startup decides whether to keep waiting.
- Readiness is reversible, liveness is not — use readiness for temporary trouble and reserve liveness for truly stuck processes, with forgiving timeouts and thresholds.
- Never tie liveness to external dependencies — a restart cannot fix a database, and doing so causes cascading restart loops and outages.
- Use a startup probe for slow applications — its budget of failure threshold times period protects start-up without weakening liveness later.
- Readiness protects rollouts — without it, Kubernetes cannot tell a broken new version from a healthy one and may replace working pods.
- Tune from measurements — the default one-second timeout is often too short under load, and copied settings rarely fit another application.
- Watch and rehearse — monitor restarts, ready counts, and probe failures, and test hangs, slow starts, and dependency outages before production does it for you.