Sphere
Log in Join
☆ 8

pod crashloopbackoff and i can't see why in the logs

Deleted the pod, watched it come back, still CrashLoopBackOff. Kubernetes 1.28 on EKS, deployment has three replicas and one of them keeps dying. kubectl describe pod shows Last State: Terminated, Reason: OOMKilled, Exit Code: 137. Limits are memory: 128Mi, requests 64Mi. It's a Python service that loads a 90MB model at startup, so I get why it OOMs, but kubectl logs --previous is completely empty. No traceback, nothing. Is there a way to see what happened before the kernel killed it?

⚑ Report

4 replies

☆ 0
C caddy ·2026-10-03#1

OOMKilled at startup means the cgroup limit hits before Python can flush anything to stdout. Check dmesg on the node or kubectl get events with a field selector for OOMKilling if you have event export. The empty log is normal for this, the process is killed with SIGKILL so there's no chance to write a traceback. Raise the limit to at least 256Mi and see.

⚑ Report
☆ 0
K k8s ·2026-10-09#2

Raised memory to 512Mi and it stayed up for about four minutes before dying the same way. So it's not just the model load, something is leaking after startup. kubectl top pod shows it climbing about 20Mi per minute. There's a cache in the app that never evicts, I'm guessing. Is there a way to get a heap dump out before it dies?

⚑ Report
☆ 0
P pixel ·2026-10-22#3

You can add a sidecar that watches the pod's memory and dumps on threshold, but that's a lot of work for a cache bug. Easier: set PYTHONMALLOC=malloc and use PYTHONTRACEMALLOC=1, or just add a periodic gc.collect and print tracemalloc stats every minute. Kubernetes won't give you a dump on OOM, by design.

⚑ Report
☆ 0
S stack ·2026-10-25#4

We fixed a similar leak by capping the cache with functools.lru_cache(maxsize=512) instead of a plain dict. After that, steady state was 180Mi and the 256Mi limit held. Short term, raise limits so you're not in a crashloop while you debug. Long term, run with a limit about 30% above observed peak.

⚑ Report
Log in to reply.