Kubernetes Exit Code 137: OOMKilled vs Node Evicted Explained

2026-11-29来源 dev.toEnglish

Exit Code 137 means a process was terminated immediately by Linux signal SIGKILL (128 + 9 = 137). In Kubernetes, this almost always points to one of two memory failures: container-level OOMKilled or node-level Evicted.

OOMKilled vs Evicted: How to Tell the Difference

  • OOMKilled (cgroup limit hit): Your container allocated more memory than its own resources.limits.memory. The Linux kernel OOM killer terminates it immediately, and kubectl describe pod shows Reason: OOMKilled.

  • Evicted (node memory pressure): Even if your Pod stayed under its own limit, the underlying worker node ran out of total RAM. The kubelet evicts Pods based on their QoS Class (BestEffort first, then Burstable).

  • livenessProbe / Graceful Timeout SIGKILL: Rarely, exit code 137 occurs when a container ignores SIGTERM during shutdown and gets force-killed after terminationGracePeriodSeconds.

30-Second kubectl Diagnosis

# Check container termination reason & QoS class kubectl get pod -o jsonpath='{.status.qosClass}{"n"}{.status.containerStatuses[0].lastState.terminated.reason}{"n"}' # Inspect kernel OOM messages on the node (if SSH/node access available) kubectl get events -A --field-selector reason=OOMKilling --sort-by='.lastTimestamp' 

How to Prevent Exit Code 137 Permanently

  • Leave 25%–30% Non-Heap Headroom for JVM/Go/Node: Never set Java -Xmx equal to the container memory limit. Account for Metaspace, thread stacks, and direct buffers using our JVM Container Memory Calculator.

  • Upgrade Critical Pods to Guaranteed QoS: Set CPU and Memory requests == limits on every container so critical services are evicted last during node pressure. Test your config with the Kubernetes QoS Class Checker.

  • Enable Memory Profiling Before Raising Limits Blindly: For Java services, follow our Native Memory Tracking (NMT) guide to pinpoint whether Heap, Direct Memory, or Threads caused the spike.

Originally published at OpsHubs. Found it useful? Buy us a coffee ☕.

原文:https://www.a8q9.cn/en/article/kubernetes-exit-code-137-oomkilled-vs-node-evicted-explained-fff5b1.html

相关文章