Pod keeps restarting in Kubernetes cluster. How do you debug–DevOps Interview Questions with Answers

Pod keeps restarting in Kubernetes cluster. How do you debug–DevOps Interview Questions with Answers

App Pod Restarting Frequently – Deep Interview Explanation

In Kubernetes, if a pod is restarting frequently, I follow a systematic troubleshooting approach starting from the Kubernetes layer to the application layer.

You can say it like this:

If a pod is restarting continuously in Kubernetes, I follow a structured troubleshooting approach from the Kubernetes layer to the application layer.

1️⃣ Check Pod Status

First, I check the pod status.

kubectl get pods

If I see errors like CrashLoopBackOff, it means the container starts but crashes repeatedly.


2️⃣ Inspect Pod Details and Events

Next, I describe the pod to check detailed information.

kubectl describe pod <pod-name>

Here I check the Events section and look for issues like:

  • Container exit codes

  • OOMKilled messages

  • Image pull errors

  • Volume mount failures

  • Probe failures

The events section usually gives the first clue about the problem.


3️⃣ Check Application Logs

Then I check container logs.

kubectl logs <pod-name>

If the container restarted already, I check previous logs.

kubectl logs <pod-name> --previous

Here I look for issues such as:

  • Application crash

  • Dependency failures

  • Database connection errors

  • Configuration issues


4️⃣ Check Resource Limits (CPU / Memory)

Sometimes pods restart due to memory exhaustion.

If I see OOMKilled, it means the container exceeded its memory limit.

Possible fixes:

  • Increase memory limits in the deployment YAML

  • Optimize application memory usage


5️⃣ Verify Liveness and Readiness Probes

If the liveness probe fails repeatedly, Kubernetes restarts the container automatically.

Possible issues include:

  • Application taking longer to start

  • Health check endpoint failing

Solutions:

  • Increase initialDelaySeconds

  • Fix the health check endpoint


6️⃣ Check Node Health

Sometimes the issue may be at the node level.

kubectl describe node <node-name>

Things I check:

  • Memory pressure

  • Disk pressure

  • CPU pressure


7️⃣ Check Configuration Issues

Pods may restart due to incorrect configuration such as:

  • Incorrect ConfigMaps

  • Missing Secrets

  • Wrong environment variables

For example, if a database connection string is incorrect, the application may crash and cause pod restarts.


8️⃣ Check External Dependencies

Finally, I check external dependencies such as:

  • Database availability

  • API connectivity

  • Network issues

If any dependency fails, the application may crash and cause the pod to restart.


Strong Closing Line (Important in Interview)

End like this:

So my troubleshooting approach is to start with pod status, then check events and logs, verify resource limits, inspect probes, check node health, and finally validate application configuration and external dependencies to identify the root cause.


Important Tip:

After this answer, interviewers often ask follow-up questions, like:

  • What causes CrashLoopBackOff?

  • Difference between liveness probe and readiness probe?

  • What is OOMKilled?

  • What is kubectl describe used for?

0 Comments