YARN/Spark: 'Container killed on request. Exit code is 143' — over memory limits or preempted.
Slow startup killed by liveness? Add a startupProbe.
Handle SIGTERM: finish in-flight work and exit within terminationGracePeriodSeconds.
Use exec-form ENTRYPOINT so Java is PID 1 and receives the signal.
✦ Definition~90s read
What is Exit Code 143?
When a process is ended by a signal, shells and container runtimes report exit code 128 + the signal number. SIGTERM is signal 15, so 143 means the process was asked to terminate. 137 (128 + 9) means it was force-killed with SIGKILL.
★
143 is someone tapping you on the shoulder and saying 'time to go'.
Plain-English First
143 is someone tapping you on the shoulder and saying 'time to go'. 137 is being carried out. Neither means your code crashed; something outside decided to stop it.
The payments pod restarted every two minutes with exit code 143 and no stack trace. Nothing crashed: the liveness probe was killing it before it finished starting.
Where 143 Comes From
Exit codes above 128 mean 'killed by signal (code - 128)'.
Look at the pod's events to see why the kubelet stopped it.
k8s.shBASH
1
2
3
kubectl describe pod payments | grep -A5 -i events
# WarningUnhealthyLiveness probe failed: connection refused
# NormalKillingContainer payments failed liveness probe, will be restarted
🎯 Key Takeaway
Events tell you who.
Slow Start? Add a startupProbe
Liveness and readiness probes don't run until the startup probe succeeds.
deploy.yamlYAML
1
2
3
4
5
6
7
startupProbe:
httpGet: { path: /health, port: 8080 }
failureThreshold: 12
periodSeconds: 10 # up to 120 s
livenessProbe:
httpGet: { path: /health, port: 8080 }
periodSeconds: 10
🎯 Key Takeaway
Give slow apps time to start.
Shut Down Gracefully
On SIGTERM, stop accepting work, finish what's in flight, and exit before terminationGracePeriodSeconds (default 30 s), or you'll be SIGKILLed (137). Use exec form so Java receives the signal.
DockerfileDOCKERFILE
1
2
ENTRYPOINT ["java", "-jar", "app.jar"] # exec form: java is PID1
# not: ENTRYPOINT java -jar app.jar (shell form: sh gets the signal)
🎯 Key Takeaway
Exec form + graceful shutdown.
● Production incidentPOST-MORTEMseverity: high
Killed Before It Was Ready
Symptom
kubectl describe showed Last State: Terminated, Exit Code: 143; app logs ended mid-startup with no error.
Assumption
The team looked for a crash in the application.
Root cause
The app needed ~60 seconds to start (cache warm-up). The liveness probe began at 10 s and failed after three 10 s checks, so the kubelet sent SIGTERM at ~30 s.
Fix
Added a startupProbe allowing 120 s; liveness only runs after startup succeeds.
Key lesson
143 means asked to stop.
Find who sent the signal.
Use startupProbe for slow starts.
Production debug guideCheck the platform, not the app3 entries
Symptom · 01
Kubernetes restarts with 143
→
Fix
kubectl describe pod: look at Events for 'Liveness probe failed' or 'Killing'.
Symptom · 02
YARN 'Container killed on request. Exit code is 143'
→
Fix
Check container memory vs limits and the ResourceManager for preemption.
Symptom · 03
143 during deploys
→
Fix
Normal rollout; make shutdown graceful.
⚙ Quick Reference
4 commands from this guide
File
Command / Code
Purpose
signals.sh
kill -l 15 # TERM
Where 143 Comes From
k8s.sh
kubectl describe pod payments | grep -A5 -i events