A readiness check answers a practical question: can this application serve requests now? The application decides what “ready” means. Kubernetes can check that answer periodically with a readiness probe. If the probe fails, the Pod is removed from its Service endpoints, but its container is not restarted. section 11.6.1
For an HTTP application, start with an `httpGet` probe. A GET request to `/` on port 8080 succeeds when the response code is at least 200 and below 400. A failed connection or another response code marks the Pod not ready. Checking `/` is better than having no probe, but it may prove only that the server responds—not that the application can do its job. section 11.6.3
Check the capability clients need
An application that serves `/quote` can probe that path instead of `/`: it should not receive traffic before it can serve a quote. For an API that needs a database, a GET `/healthz/ready` handler can attempt a database connection, return HTTP 500 on failure, and return HTTP 200 on success. The probe then reflects a dependency the API needs to serve requests. section 11.6.3
Listing 11.12 The readiness endpoint in the quiz-api application
func (s *HTTPServer) ListenAndServe(listenAddress string) {
router := mux.NewRouter()
router.Methods("GET").Path("/").HandlerFunc(s.handleRoot)
router.Methods("GET").Path("/healthz/ready").HandlerFunc(s.handleReadiness) #1
...
}
func (s *HTTPServer) handleReadiness(res http.ResponseWriter, req *http.Request) {
conn, err := s.db.Connect() #2
if err != nil { #3
res.WriteHeader(http.StatusInternalServerError) #3
_, _ = fmt.Fprintf(res, “ERROR: %v\n”, err.Error()) #3
return #3
}
defer conn.Close()
res.WriteHeader(http.StatusOK) #4
_, _ = res.Write([]byte("Readiness check successful")) #4
}
The Go handler shows an application-provided readiness endpoint: it tests a database connection and reports the result through the HTTP response code. section 11.6.3
The readiness endpoint supplies the answer; the Pod’s probe asks for it. Probe settings control timing and the number of failures or successes needed to change status. A Pod can remain Running while not ready, and a ReplicaSet does not replace it merely because its readiness probe keeps failing. Check the Pod’s READY column and its EndpointSlice ready condition when diagnosing missing Service traffic. section 11.6.1 section 11.6.2 section 14.3.2






