Search code examples
kubernetes

Reasons for OOMKilled in kubernetes


I try to get a general understanding of OOMKilled events and I've found 2 different reasons:

  1. Pod memory limit exceeded: If the Container continues to consume memory beyond its limit, the Container is terminated.

  2. Node out of memory: If the kubelet is unable to reclaim memory prior to a node experiencing system OOM, ... then kills the container ...

Questions

  • Is this correct?
  • Are there any other reasons?
  • Is it possible to see which reason caused the OOMKilled? (It's important to know the reason, because the remedy will be different.)

Solution

  • Both problems result in different error states:

    1: An exceeded pod memory limit causes a OOMKilled termination

    2: Node out of memory causes a MemoryPressure and and pod eviction.

    kubectl describe pod mypod-xxxx
    
    ...
    Reason:         Evicted
    Message:        Pod The node had condition: [MemoryPressure].
    ...