Operations 3 min read

How to Diagnose and Fix Constant Kubernetes Pod Restarts (OOM)

When a Kubernetes pod repeatedly restarts, you can pinpoint the cause by inspecting events, describing the pod, and checking previous logs, then identify OOM kills caused by memory limits in the deployment.yaml and resolve it by increasing the memory limit and redeploying the pod.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Diagnose and Fix Constant Kubernetes Pod Restarts (OOM)

Summary : Kubernetes issue diagnosis – continuous pod restarts, how to locate the cause and resolve it.

When performing performance testing, we often find our pod services repeatedly restart; using kubectl get pods we can gradually locate the problem.

Phenomenon : a running pod restarts too many times in a short period.

Pod restart illustration
Pod restart illustration

Problem identification method : view pod logs.

kubectl get event                           # view events from the past hour
kubectl describe pod pod_name               # describe the current pod
kubectl logs -f pod_name --previous          # view the pod logs before the restart, starting from that point

###############
Usually the above three commands are sufficient.
In this case we used the following command to solve the issue:

kubectl describe pod pod_name

Problem cause : OOM, pod was killed and restarted (insufficient memory).

OOM cause illustration
OOM cause illustration

View the service's deployment.yaml file

deployment.yaml snippet
deployment.yaml snippet

We discovered that the deployment.yaml set memory limits for the service.

Solution : increase the memory limit value, then delete the old resources with kubectl delete -f yaml and apply the updated configuration with kubectl apply -f yaml.

Thus we successfully solved the problem and identified the root cause.

Link: https://bbs.huaweicloud.com/blogs/413818

© Huawei Cloud Community. All rights reserved. Original author.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

KubernetesOOMPod RestartMemory Limits
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.