Kubernetes Health Probes: Liveness, Readiness, and Startup Explained
You've deployed your app to Kubernetes. The pod starts — then it gets killed. Or it's running but no traffic reaches it. Or it takes 90 seconds to initialize and gets restarted in a loop. Every one of these problems traces back to the same root cause: misconfigured or missing health probes . Kubernetes gives you three types of probes: livenessProbe , readinessProbe , and startupProbe . Each serves a different purpose. Mix them up and your pods restart in infinite loops. Get them right and your deployments self-heal, scale correctly, and handle rolling updates without a single dropped request. Here's what each probe does, when to use it, and how to configure it for a real production service. 1. Liveness Probe: Is the Container Alive? The liveness probe answers one question: "Is this container still running correctly?" If the probe fails, kubelet kills the container and restarts it. livenessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 5 periodSeconds: 10 failureThreshold: 3 Use liveness probes for deadlock detection . If your app enters a state where it's alive but not making progress (a goroutine leak, a stuck mutex, an infinite loop), the liveness probe exposes that and triggers a restart. The #1 mistake people make: using the liveness probe to check external dependencies like databases or upstream APIs. Don't do this. If your database is down and your liveness probe fails, Kubernetes will restart your pod — but the database is still down. Restarting the app doesn't help, and now you have a crash loop on top of a DB outage. That's worse. Liveness probes should only check internal process health. Not database connectivity, not Redis, not upstream services. 2. Readiness Probe: Is the Container Ready for Traffic? The readiness probe answers: "Should this pod receive traffic?" If it fails, the pod is removed from all Service endpoints. It is not restarted. readinessProbe: httpGet: path: /ready port: 8080 periodSeconds: 5 failureThreshold: 2 successThre