KubernetesPodCrashLooping #
Pod {{ $labels.namespace }}/{{ $labels.pod }} is crash looping
Alert Rule
alert: KubernetesPodCrashLooping
annotations:
description: |-
Pod {{ $labels.namespace }}/{{ $labels.pod }} is crash looping
VALUE = {{ $value }}
LABELS = {{ $labels }}
runbook: https://srerun.github.io/prometheus-alerts/runbooks/kubestate-exporter/kubernetespodcrashlooping/
summary: Kubernetes pod crash looping ({{ $labels.namespace }}/{{ $labels.pod }})
expr: increase(kube_pod_container_status_restarts_total[1m]) > 3
for: 2m
labels:
severity: warning
Here is a runbook for the KubernetesPodCrashLooping alert:
Meaning #
The KubernetesPodCrashLooping alert is triggered when a pod in a Kubernetes cluster is experiencing a crash loop, meaning it is repeatedly crashing and restarting within a short period of time. This can indicate a problem with the pod’s configuration, the container image, or the underlying infrastructure.
Impact #
A crash looping pod can have several negative impacts on the cluster and application:
- Resource waste: The repeated restarts can consume excess resources such as CPU and memory, leading to performance issues and increased costs.
- Service disruption: If the pod is part of a critical service, the crash loop can cause service degradation or unavailability, affecting end-users.
- Data loss: In extreme cases, a crash looping pod can lead to data loss or corruption if the pod is responsible for writing data to a database or file system.
Diagnosis #
To diagnose the root cause of the crash looping pod, follow these steps:
- Check the pod’s logs using
kubectl logs
to identify the error message or exception that is causing the crash. - Verify the pod’s configuration and resources using
kubectl describe pod
to ensure they are correct and sufficient. - Check the container image for any known issues or bugs that may be causing the crash.
- Review the pod’s events and status using
kubectl get events
andkubectl get pod
to identify any patterns or clues.
Mitigation #
To mitigate the effects of the crash looping pod, follow these steps:
- Immediately scale down or delete the problematic pod to prevent further resource waste and service disruption.
- Investigate and fix the root cause of the crash loop, using the diagnosis steps above as a guide.
- Implement a fix, such as updating the container image or configuration, and redeploy the pod.
- Monitor the pod’s behavior and performance after the fix to ensure it is stable and functioning correctly.
Remember to follow your organization’s incident response and change management processes when mitigating this issue.