https://drive.google.com/file/d/1l0bQJNRRjrxzuIn0dwAb4AMbM67MIgrp/view?usp=sharing
apiVersion: v1
kind: Pod
metadata:
name: nnappone
namespace: learning
labels:
app: nnappone
spec:
containers:
- name: crackone-app
image: lovelearnlinux/stress:latest # β Special image with `stress` tool
resources:
requests:
memory: "150Mi" # Scheduler reserves 150Mi
limits:
memory: "250Mi" # Hard ceiling = 250Mi
command: ["stress"]
args: ["--vm", "1", "--vm-bytes", "275M", "--vm-hang", "1"]
π₯ What the stress command does:
-vm 1β Start 1 worker-vm-bytes 275Mβ Allocate 275 MB of memory-vm-hang 1β Lock the memory (donβt release it)
β οΈ Conflict:
Pod tries to use 275 MB > limit = 250 MiB β Killed by OOM Killer!
π Note: 275M (Megabytes = 1000Β²) β 262 MiB (Mebibytes = 1024Β²) β still > 250 MiB
| Phase | What Occurs |
|---|---|
| 1. Scheduling | β Success! Node has β₯150Mi free β Pod starts |
| 2. Container Runs | stress allocates memory β reaches ~262 MiB |
| 3. Memory > 250MiB | Container Runtime (containerd/docker) triggers OOM Killer |
| 4. Pod Status | Changes to OOMKilled β restarts (if restartPolicy: Always) |
| 5. Event Logged | Exit Code 137 = 128 + 9 β signal SIGKILL |
π‘ Key Difference from CPU:
- CPU overuse β throttled (slowed, but survives)
- Memory overuse β killed immediately (no second chances!)
# 1. Create namespace
kubectl create namespace learning
# 2. Apply the Pod
kubectl apply -f pod-with-memory-exceed.yml
# 3. Watch it crash
kubectl get pods -n learning -w
# β
Youβll see:
# nnappone 0/1 OOMKilled 1 (or more) 10s
# 4. Describe Pod β look for OOM event
kubectl describe pod nnappone -n learning
# π Critical lines in "Events":
# Last State: Terminated
# Reason: OOMKilled
# Exit Code: 137
# ...
# Restart Count: 2+
# 5. Check logs (may be empty if killed instantly)
kubectl logs nnappone -n learning --previous
# 6. Clean up
kubectl delete pod nnappone -n learning
kubectl delete namespace learning
| Signal | Meaning |
|---|---|
| SIGKILL (9) | Force-kill process (canβt be caught/ignored) |
| Exit Code = 128 + 9 = 137 | Standard way to indicate killed by SIGKILL |
β In Kubernetes:
Exit Code 137 + Reason: OOMKilled = memory limit exceeded