Azure 61: Health Probes — Liveness, Readiness & Startup
easy⏱ 5 mincourseazure
Three probes, three questions
Liveness asks 'are you alive?' — fail it and AKS restarts the pod. Readiness asks 'can you serve traffic?' — fail it and the pod is pulled from the Service load balancer (no restart). Startup asks 'have you finished booting?' — it holds the other probes off for slow starters. Mixing up liveness and readiness is the classic outage: a dependency blip restarts healthy pods instead of just draining them.
# deployment.yaml
readinessProbe:
httpGet: { path: /healthz/ready, port: 8080 }
periodSeconds: 5
failureThreshold: 3
livenessProbe:
httpGet: { path: /healthz/live, port: 8080 }
periodSeconds: 10
Readiness = dependencies
A pod is ready only when the things it needs are reachable — the database, the cache, a downstream API. Readiness should check those (cheaply), while liveness should stay dumb (just 'is the process responsive?') so a slow database never triggers a restart storm.
Model the readiness check
Write a readiness(deps) taking a record of dependency name → healthy boolean; return { ready } true only if ALL are healthy, else the first unhealthy name as reason. Simulate three checks and console.log READY or NOT READY: <dep>.
Cache the dependency checks
Don't hammer your database on every readiness probe (every 5s × every pod). Cache the result for a few seconds — readiness must be fast and cheap, or the probe itself becomes the outage.
Quiz: which probe restarts the pod?
Failing which probe makes AKS restart the pod? Liveness — readiness only removes it from the load balancer; startup just delays the others.