Quick revision
The short answer
A liveness probe tells Kubernetes whether to restart the container, a readiness probe whether to send it traffic, and a startup probe holds off the other probes until a slow-starting application is up. Spring Boot Actuator exposes /actuator/health/liveness and /actuator/health/readiness, enabled automatically on Kubernetes or with management.endpoint.health.probes.enabled=true, backed by the LivenessState and ReadinessState that the application changes through AvailabilityChangeEvent, with readiness switching to REFUSING_TRAFFIC during shutdown.
What to remember
In this answer, we saw that liveness decides restarts, readiness decides traffic, and the startup probe protects slow starters from liveness checks. Spring Boot Actuator exposes /actuator/health/liveness and /actuator/health/readiness, enabled on Kubernetes or with management.endpoint.health.probes.enabled=true, backed by LivenessState and ReadinessState that the application can change with AvailabilityChangeEvent, and readiness switches to REFUSING_TRAFFIC during shutdown. We configured timings with a startup probe and reasonable timeouts and failure thresholds.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A liveness probe tells Kubernetes whether to restart the container, a readiness probe whether to send it traffic, and a startup probe holds off the other probes until a slow-starting application is up. Spring Boot Actuator exposes /actuator/health/liveness and /actuator/health/readiness, enabled automatically on Kubernetes or with management.endpoint.health.probes.enabled=true, backed by the LivenessState and ReadinessState that the application changes through AvailabilityChangeEvent, with readiness switching to REFUSING_TRAFFIC during shutdown.
Why this question is asked
Probes are how Kubernetes decides what to do with our pods, and wrong probes cause some of the most confusing outages: services restarted in loops, traffic sent to pods that are not ready, or slow starters killed before they finish booting. Interviewers ask about them to check that we understand the difference between the three and how Spring Boot connects them to the application's own state. In this answer, we will recap what each probe does, see how Actuator exposes them, look at the availability states behind them, and configure timings that fit a Spring Boot service.
1A Quick Recap: Three Probes, Three Questions
The kubelet, the Kubernetes agent on each node, runs probes against every container at a regular interval. Each probe is an HTTP request, a TCP connection or a command, and it either succeeds or fails. After a configured number of failures in a row, the kubelet acts, and what it does depends on the probe.
The liveness probe answers: is this process broken in a way only a restart can fix? If it fails, the kubelet kills and restarts the container. The readiness probe answers: should this pod receive traffic right now? If it fails, the pod is removed from the Service's endpoints, so no new requests reach it, but it is not restarted. The startup probe answers: has the application finished starting? While it runs, liveness and readiness are not checked; once it succeeds, they take over. If it never succeeds within its limit, the container is restarted.
| Probe | Question | On failure |
|---|---|---|
| Startup | Has the app finished starting? | keep waiting; restart after the limit |
| Liveness | Is the process broken beyond self-repair? | restart the container |
| Readiness | Should it receive traffic now? | remove from Service endpoints, no restart |
2How Spring Boot Actuator Exposes the Probes
Spring Boot Actuator provides health groups for the probes: /actuator/health/liveness and /actuator/health/readiness. They are enabled automatically when Spring Boot detects that it runs on Kubernetes, which it does by looking for the KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT environment variables, and we can enable them anywhere with a property. Since the main /actuator/health endpoint must be exposed for the groups to be reachable, the health endpoint needs to be in the web exposure list, which it is by default.
We then point the Kubernetes probes at these paths. The startup probe usually reuses the liveness path, because what we want to know at startup is simply whether the application is up.
3The Availability States Behind Them
The probe endpoints are not just a list of checks; they reflect the application's availability state, which Spring Boot tracks through ApplicationAvailability. LivenessState is CORRECT or BROKEN, and ReadinessState is ACCEPTING_TRAFFIC or REFUSING_TRAFFIC. Spring Boot sets them itself during the lifecycle: liveness becomes CORRECT once the context has refreshed, and readiness becomes ACCEPTING_TRAFFIC once the application and command-line runners have finished. That is why a service that warms a cache in an ApplicationRunner only reports ready after the warm-up.
The application can change these states by publishing an AvailabilityChangeEvent. For example, a component that detects an unrecoverable internal fault can mark liveness BROKEN, and a component that is reloading a large data set can refuse traffic for a while.
During shutdown, Spring Boot publishes REFUSING_TRAFFIC itself when the context starts closing, so the readiness probe fails while in-flight requests finish. Notice that the HTTP status matters, not the JSON: the kubelet treats 200 to 399 as success and anything else as failure.
4Configuring the Probes in Kubernetes
Timings must fit the application. A Spring Boot service that takes 40 seconds to start under load would be killed by a liveness probe with a short initial delay. The modern answer is a startup probe with enough budget, rather than a long initialDelaySeconds on liveness, because the startup probe ends as soon as the app is up, while an initial delay always waits its full length.
The timeout deserves attention too. The Kubernetes default is one second, and a JVM in a long garbage collection pause, or a probe stuck behind busy request threads, can miss it. A slightly longer timeout and a few failures before acting avoid restarts caused by a single slow moment.
5Follow-up questions
Should the database health be part of liveness?
No. If the database is down, restarting our pod does not fix it, and restarting every pod at once makes recovery slower. By default Spring Boot's liveness group includes only the liveness state, and that is the right choice. Readiness may include a dependency, but only when removing the pod from traffic actually helps.
What is the difference between /actuator/health and the probe paths?
/actuator/health aggregates every health indicator, such as the database, disk space and message brokers. The probe paths are health groups that by default contain only the availability states. Using /actuator/health for liveness ties restarts to the health of external systems, which is a common cause of restart storms.
Can the probes be served on the main port when management uses another port?
Yes. With management.endpoint.health.probes.add-additional-paths=true, Spring Boot also serves /livez and /readyz on the main server port. That way the probes check the same web server that handles traffic, even if the rest of Actuator runs on a separate management port.
6Conclusion
In this answer, we saw that liveness decides restarts, readiness decides traffic, and the startup probe protects slow starters from liveness checks. Spring Boot Actuator exposes /actuator/health/liveness and /actuator/health/readiness, enabled on Kubernetes or with management.endpoint.health.probes.enabled=true, backed by LivenessState and ReadinessState that the application can change with AvailabilityChangeEvent, and readiness switches to REFUSING_TRAFFIC during shutdown. We configured timings with a startup probe and reasonable timeouts and failure thresholds.
Open with
Kubernetes has three probes, and the difference is what happens on failure. Liveness asks whether the process is broken in a way only a restart fixes, so failing it restarts the container.
Then, if they want more
Readiness asks whether the pod should get traffic now; failing it removes the pod from the Service endpoints but does not restart it. The startup probe is for slow starters: while it runs, liveness and readiness are paused, and once it succeeds they take over. Spring Boot Actuator supports this with health groups at /actuator/health/liveness and /actuator/health/readiness.
They are enabled automatically when Boot detects Kubernetes, or with management.endpoint.health.probes.enabled. Behind them are availability states: LivenessState CORRECT or BROKEN, and ReadinessState ACCEPTING_TRAFFIC or REFUSING_TRAFFIC. Boot sets them during startup, readiness only after runners finish, and on shutdown readiness goes to REFUSING_TRAFFIC so the pod leaves rotation.
The application can change them itself by publishing an AvailabilityChangeEvent, for example refusing traffic during a reload. For timings, I use a startup probe with a generous failure threshold instead of a long initial delay on liveness, and timeouts of a couple of seconds with a few failures before acting, so one GC pause does not restart the pod.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Kubernetes documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Explain liveness, readiness and startup probes in Kubernetes and how Spring Boot...": https://scrivio-interview-library.netlify.app/spring-boot/containers-and-kubernetes/465f0c44fd/