Introduction
What exit code 137 means for Kubernetes
Exit code 137 is a signal that occurs when a container's memory exceeds the memory limit provided in the pod specification. When a container consumes too much memory, Kubernetes kills it to protect it from consuming too many resources on the node. This ensures that other containers on the same node are able to keep running normally.
Steps we'll cover:
- Dive into Exit Code 137
- Kubernetes and Exit Code 137
- Common Causes for Memory Issues in Containers
- Steps to Mitigate Memory Issues
- Techniques to Investigate Application Memory Consumption
Importance of troubleshooting this exit code for maintaining a stable environment
Troubleshooting this issue will reduce your maintenance overhead and help prevent inconsistencies caused by unexpected service interruptions. However, there are some causes of exit code 137 that may be specific to your environment, but most of the time, you can solve it using a simple troubleshooting procedure. Always remember that any problem that causes disruption is a business loss. We must be vigilant about this issue and attempt to permanently resolve it.
Background: Exit Codes Explained
What are exit codes and their significance?
When a container terminates, container engines utilize exit codes to report why it was terminated. Exit codes serve as a way to inform the user, operating system, and other applications about why the process was terminated. Each code is a number ranging from 0 to 255. Codes below 125 have application-specific meanings, whereas higher values have special meanings.
Common exit codes and what they generally indicate
Container failures are one of the most common causes of Kubernetes pod exceptions, and understanding container exit codes will assist you in determining the root cause of pod failures while troubleshooting. Containers most commonly utilize the following exit codes:
Error Codes | What they indicate |
---|---|
Exit Code 0 | This Exit Code is triggered by developers when they terminate their container on purpose once a task is completed. Exit Code 0 technically indicates that the foreground process is not associated with a specific container. |
Exit Code 1 | This Exit Code indicates that the container stopped due to an application error or an incorrect image specification reference. |
Exit Code 125 | Exit Code 125 indicates that the container is being run by the command. In the system shell, for example, the docker run was invoked but did not execute correctly. |
Exit Code 126 | Exit Code 126 indicates that the command used for a container specification could not be invoked. In a continuous integration script used to run a container, this is often the cause of a missing dependency or error. |
Exit Code 127 | Exit Code 127 shows that a command used in the container specification points to a file or directory that doesn't exist. |
Exit Code 128 | Exit Code 128 refers to the fact that the code running from your container has successfully completed an exit command but was not able to produce a valid exit code. |
Dive into Exit Code 137
Meaning and implications of exit code 137
The out-of-memory (OOM) killer is an operating system's mechanism used to terminate running processes when there is not enough available memory, and thus, it generates the exit code 137.