If you have ever sat across from a Senior Platform Engineer in a Kubernetes interview, you have likely heard some variation of this scenario:
"Imagine your application is running inside a Pod. kubectl get pods shows the status as Running, and the container process hasn't crashed. However, the application itself is completely deadlocked and not responding to requests. How does Kubernetes detect this, and how do you configure it to recover automatically?"
When I interview candidates for DevOps and Platform Engineering roles, I love asking this question because it separates people who have just memorized kubectl commands from engineers who actually understand how distributed systems fail in production.
Let’s break down why this happens, how to answer the interview question clearly, and how to troubleshoot and fix it in the real world.
1. Understanding the Root Cause: Why Kubernetes Doesn't Automatically Know
To solve this, you first have to understand what Kubernetes actually monitors by default.
By default, the kubelet (the node agent responsible for managing Pods) only monitors the Operating System process (PID 1) inside your container via the container runtime (like containerd).
If your application throws an unhandled exception and exits with code 1, the container process dies. The kubelet sees PID 1 terminate, checks the Pod's restartPolicy (which defaults to Always), and immediately restarts the container.
The problem is a silent failure (or Zombie Pod):
- Your Java app hits a thread deadlock.
- Your Node.js event loop gets blocked by a synchronous infinite loop.
- Your Go service runs out of database connection pool slots and hangs indefinitely.
In all these cases, the OS process (PID 1) is still alive. Because the process hasn't exited, Docker/containerd tells the kubelet, Everything is fine! Meanwhile, Kubernetes Services keep routing user traffic to that frozen Pod, causing 502/504 Gateway Timeouts for your users.
2. The Solution: Kubernetes Probes
To bridge the gap between "the process is running" and "the application is actually working," Kubernetes uses Probes—periodic diagnostic checks executed by the kubelet against your container.
In your interview, you should highlight two specific probes that work together to handle this scenario:
1. The Liveness Probe (The Recovery Mechanism)
The Liveness Probe answers one question: "Is this application stuck in an unrecoverable state?"
How it detects the issue: The kubelet periodically sends a request (HTTP GET, TCP socket check, gRPC call, or an exec command) to the container. If the application is deadlocked, it won't respond before the timeoutSeconds limit.
How it recovers: Once the probe fails consecutive times equal to failureThreshold, the kubelet marks the container as unhealthy, kills the container, and restarts it according to the Pod's restartPolicy. This clears the deadlock and brings up a fresh instance.
2. The Readiness Probe (The Traffic Protection Mechanism)
While the Liveness Probe restarts the container, restarting takes time. What happens to user traffic during those 15–30 seconds while Kubernetes is waiting for the Liveness Probe to hit its failure threshold?
How it helps: The Readiness Probe answers: Is this Pod ready to accept live traffic right now?
How it protects users: If a Readiness Probe fails, Kubernetes does not restart the container. Instead, the EndpointSlice controller immediately removes the Pod's IP address from the Service's load-balancing pool. Traffic is instantly routed to other healthy Pods while the Liveness Probe handles restarting the broken one.
Bonus Interview Tip: Mention the Startup Probe if the interviewer asks about slow-booting legacy apps—it disables liveness and readiness checks until the app finishes booting so Kubernetes doesn't accidentally kill a slow-starting app.
3. Production-Ready Configuration Example
Here is how you should structure your Deployment YAML to handle a frozen application gracefully. Notice how the Readiness Probe is configured to fail fast (to stop traffic immediately), while the Liveness Probe is slightly more forgiving (to avoid unnecessary restarts during brief CPU spikes).
apiVersion: apps/v1
kind: Deployment
metadata:
name: payment-service
spec:
replicas: 3
selector:
matchLabels:
app: payment-service
template:
metadata:
labels:
app: payment-service
spec:
containers:
- name: payment-api
image: myrepo/payment-api:v1.4.2
ports:
- containerPort: 8080
# 1. Protects slow-starting apps from premature kills
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 2 # Gives the app up to 60 seconds to boot
# 2. Cuts off user traffic immediately if the app hangs or loses DB access
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 2 # Cuts traffic after 10 seconds of unresponsiveness
# 3. Kills and restarts the container if the process is truly deadlocked
livenessProbe:
httpGet:
path: /healthz
port: 8080
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3 # Restarts container after 30 seconds of hanging
4. Step-by-Step Troubleshooting Guide (When It Happens in Real Life)
If you are on-call and suspect you have a Zombie Pod in production, follow these exact steps to diagnose and fix it:
Step 1: Confirm the Symptom
Check the Pod status and restart count. A frozen app with no Liveness Probe will show 1/1 Running with 0 restarts, even though users are reporting errors.
kubectl get pods -l app=payment-service
Step 2: Inspect Pod Events and Probe Configuration
Run describe on the Pod to see if probes are configured and whether the kubelet has recorded any Unhealthy events.
kubectl describe pod <pod-name>
Look at the Events section at the bottom. If a probe is working, you will see:Warning Unhealthy 10s (x3 over 30s) kubelet Liveness probe failed: Get "http://10.244.1.5:8080/healthz": context deadline exceeded.
**Step 3: Check Service Endpoints
Verify whether the Pod's IP is still actively receiving traffic from the Kubernetes Service.
kubectl get endpoints payment-service
If the frozen Pod's IP is still listed here, it means your Readiness Probe is either missing or misconfigured, and the Pod is actively dropping user requests.
Step 4: Test the Health Endpoint Directly
Exec into the container (or spin up an ephemeral debug container) and hit the health endpoint locally to see if the app responds or hangs.
kubectl exec -it <pod-name> -- curl -v http://localhost:8080/healthz
If curl hangs and times out, you have confirmed an application-level deadlock. (Note: Grab a thread dump or heap dump before killing it so your developers can fix the underlying code bug!)
Step 5: Implement and Tune the Probes
Add distinct /healthz (liveness) and /ready (readiness) endpoints to your application:
Golden Rule for Liveness (/healthz): Keep it lightweight! It should only verify that the application's internal event loop/threads are responsive. Never check external dependencies (like a database or third-party API) in a Liveness Probe. If your database goes down for 10 seconds, you don't want Kubernetes restarting all your application Pods in a cascading failure.
Golden Rule for Readiness (/ready): Put your dependency checks here. If the database goes down, Readiness fails, traffic pauses cleanly, and your Pods stay alive waiting for the DB to recover.
Wrapping Up Your Interview Answer
If you want to nail this question in under 60 seconds during an interview, structure your answer like this:
Explain the limitation: By default, Kubernetes only checks if PID 1 is alive, so a deadlocked process looks healthy to the kubelet.
Name the exact solution: I would configure both a Liveness Probe and a Readiness Probe.
Explain the mechanics: The Readiness Probe immediately removes the Pod's IP from the Service's EndpointSlice so users stop hitting the deadlocked Pod, while the Liveness Probe detects the timeout, kills the container, and triggers the kubelet to restart it automatically.
Drop a senior-level best practice: I'd also make sure the Liveness Probe doesn't check external databases so we don't trigger a restart storm if a downstream service blips.


Top comments (1)
Good walkthrough. One trap on the liveness side: if /healthz is served by a thread or event-loop path that is separate from the code that deadlocks, it keeps answering 200 while the app is stuck and the probe never fires. For a hung worker pool, have the handler check a heartbeat the workers update (a last-loop timestamp, say) and fail when it is older than some bound.
Also worth saying in the interview: when readiness depends on a shared database, a DB blip fails readiness on every replica at once. The Service ends up with zero endpoints and users get errors even though the pods are fine. Some teams keep readiness local to the pod and handle DB loss in the app (degraded mode, circuit breaker) for that reason.