Thuta Learning
IntermediateDevOpsintermediate

Health Checks (Probes)

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand Health Checks (Probes) without feeling intimidated by them
  • Get comfortable running the kubectl commands/YAML yourself
  • Be able to apply this concept immediately in a real project

Let's think about it this way for a second

A container process might not crash, but the app could still be deadlocked (unable to respond to requests) — from Kubernetes's point of view, the container just keeps showing as 'Running' (since the process itself is still alive). A Liveness Probe periodically checks whether the app is actually working, and restarts the container if it fails. A Readiness Probe checks whether the app is ready to accept traffic — if it fails, the Service holds off sending traffic to that pod for a while (especially useful for apps with slow container startup).

Let's connect this to a real scenario

Say a web app has a `/healthz` endpoint, and the Liveness Probe sends an HTTP request every 10 seconds — if it doesn't get a 200 response, the container gets restarted. If an app has a slow database connection pool setup, a Readiness Probe means the Service won't send traffic during that startup window, only once setup is done — protecting users from hitting errors.

Let's look at it together

yaml
apiVersion: v1
kind: Pod
metadata:
  name: web-with-probes
spec:
  containers:
    - name: web
      image: my-app:latest
      livenessProbe:
        httpGet:
          path: /healthz
          port: 8080
        periodSeconds: 10
      readinessProbe:
        httpGet:
          path: /ready
          port: 8080
        initialDelaySeconds: 5
        periodSeconds: 5
You should see
$ kubectl describe pod web-with-probes
...
Liveness:   http-get http://:8080/healthz delay=0s timeout=1s period=10s
Readiness:  http-get http://:8080/ready delay=5s timeout=1s period=5s

5-Minute Try-It

Write YAML for a pod with both a Liveness and a Readiness probe, apply it, then confirm the probe config with `kubectl describe pod`.

A Quick Word of Caution

Don't use the same endpoint for both the Liveness Probe and the Readiness Probe — Liveness asks 'am I still alive' (a light check), while Readiness asks 'can I accept traffic yet' (which can include dependency checks). They serve different purposes.

Easy traps

  • Writing a Liveness Probe endpoint that depends on the database — if the database gets slow, the app itself might be fine but the container can still fall into a restart loop
  • Setting initialDelaySeconds shorter than the app's actual startup time — the probe can fail while the app is still starting up and trigger a restart loop

Now Try It Yourself

Write YAML for a pod with both a Liveness and a Readiness probe, apply it, then confirm the probe config with `kubectl describe pod`.

You'll know it worked when: $ kubectl describe pod web-with-probes ... Liveness: http-get http://:8080/healthz delay=0s timeout=1s period=10s Readiness: http-get http://:8080/ready delay=5s timeout=1s period=5s

Health Checks (Probes) | Thuta Learning