Health checks
Liveness and readiness, gently.
Health checks are how you tell Kubernetes whether your app is actually working, not just whether its process is running. They are the small addition that turns basic self-healing into reliable self-healing. Think of them as two questions Kubernetes asks your app: "are you alive?" and "are you ready for customers?"
Liveness and readiness
There are two main probes, and the difference matters. A liveness probe asks "is this app still alive, or has it hung?" — if it fails, Kubernetes restarts the container, which rescues an app that is stuck (frozen, deadlocked) even though its process is technically still running. A readiness probe asks "is this app ready to receive traffic right now?" — if it fails, Kubernetes stops sending requests to that pod (removes it from the Service) until it passes again, without restarting it. So liveness fixes a broken app by restarting it; readiness protects users by routing around a pod that is not ready (still starting up, or temporarily busy). A probe can be an HTTP request to a health endpoint, a TCP connection check, or a command run inside the container — whatever best reflects "is my app healthy?".
spec:containers:- name: webimage: my-app:1.4readinessProbe: # "ready for traffic?" → if no, stop sending requestshttpGet: { path: /ready, port: 8080 }initialDelaySeconds: 5livenessProbe: # "still alive?" → if no, RESTART the containerhttpGet: { path: /healthz, port: 8080 }periodSeconds: 10# readiness = route around a not-ready pod ; liveness = restart a hung one.
Why probes make everything safer
Probes are what let Kubernetes tell "running" from "working", and that distinction powers several things you have already met. During a rolling update, the new pods only count as ready when their readiness probe passes — so a broken new version stalls the rollout instead of replacing all your healthy pods (this is why the earlier lesson insisted on a readiness probe for safe releases). During normal operation, readiness keeps traffic away from pods that are still starting or briefly overloaded, so users do not hit errors. And liveness quietly restarts apps that have hung, healing failures that crash-detection alone would miss. A word of care: probes need to be set thoughtfully — a liveness probe that is too aggressive can restart a healthy-but-slow app in a loop, and one pointed at the wrong thing can cause needless restarts. But a sensible readiness probe (and usually a gentle liveness probe) on your apps is one of the highest-value habits in Kubernetes: it is the difference between an app that merely runs and one that Kubernetes can actually keep healthy and roll out safely.