how to found the Killed reason of the app in kubernetes pods
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
When working with Kubernetes, it's common to encounter scenarios where your applications (running within pods) are unexpectedly killed or restarted. Understanding why your pod has been terminated is crucial for maintaining the health and performance of your applications. There are several reasons why a pod might be killed, ranging from issues with resource allocation to internal errors. In this article, we will explore the various causes of pod termination in Kubernetes and how to diagnose these issues.
Common Reasons for Pod Termination
- Resource Exhaustion:
- CPU and Memory Limits: Kubernetes allows you to define resource requests and limits for containers. If a container exceeds its CPU or memory limits, the Kubernetes scheduler may terminate the pod. The container runtime, such as `Docker`, may also kill the pod when memory limits are exceeded (`OutOfMemory (OOM)` error).
- Example: Suppose a pod is allocated 512Mi of memory, but the application requests more than that limit. Upon exceeding the limit, the pod gets terminated by the system.
- Liveness and Readiness Probes:
- Failed Probes: Kubernetes uses liveness and readiness probes to monitor the health of containers. If a liveness probe fails, Kubernetes kills the container to start a new one. Repeated probe failure will cause pod termination and restarts.
- Example:
- Resource Pressure: If the node hosting the pod runs short of resources, the kubelet will evict pods to relieve pressure.
- Node Failure: If a node goes down or becomes unresponsive, any pods scheduled on that node will be killed and rescheduled on another node.
- Rolling Updates or Re-deployments: During a deployment update, existing pods might be terminated as part of the rollout strategy to deploy new versions.
- Manual Deletions: Pods might be deleted manually by users for various reasons, including debugging or manual scaling down.
Related reading
- How to generate YAML template with kubectl command?
- How to get a custom healthcheck path in a GCE L7 balancer serving a Kubernetes Ingress?
- How to get a PDF/print version of kubernetes' docs?
- How to get all Kubernetes pod IP in each pods?
- How to get a complete list of object's methods and attributes?
- How to get a thread and heap dump of a Java process on Windows that's not running in a console
- how to get container host machine ip address and container name in EKS
- How to get current date in Helm

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.