Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
If a pod has a CrashLoopBackOff
status, then the pod probably failed or exited unexpectedly, and the log contains an exit code that isn't zero. Here are several possible reasons why your pod is stuck in CrashLoopBackOff
mode:
- Application failure: The application inside the container crashes shortly after starting, often due to misconfigurations, missing dependencies, or incorrect environment variables.
- Incorrect resource limits: If the pod exceeds its CPU or memory resource limits, Kubernetes might kill the container. This issue can happen if resource requests or limits are set too low.
- Missing or misconfigured ConfigMaps/Secrets: If the application relies on configuration files or environment variables stored in ConfigMaps or Secrets but they're missing or misconfigured, the application might crash.
- Image pull issues: If there's an issue with the image (for example, it's corrupted or has an incorrect tag), the container might not start properly and fail repeatedly.
- Init containers failing: If the pod has init containers and one or more fail to run properly, the pod will restart.
- Liveness/Readiness probe failures: If liveness or readiness probes are misconfigured, Kubernetes might detect the container as unhealthy and restart it.
- Application dependencies not ready: The application might depend on services that aren't yet ready, such as databases, message queues, or other APIs.
- Networking issues: Network misconfigurations can prevent the application from communicating with necessary services, causing it to fail.
- Invalid commands or arguments: The container might be started with an invalid
ENTRYPOINT
, command, or argument, leading to a crash.
For more information about the container status, see Pod Lifecycle - Container states.
Consider the following options and their associated kubectl commands.
Option | kubectl command |
---|---|
Debug the pod itself | kubectl describe pod <pod-name> |
Debug the replication controllers | kubectl describe replicationcontroller <controller-name> |
Read the termination message | kubectl get pod <pod-name> --output=yaml |
Examine the logs | kubectl logs <pod-name> |
Note
A pod can also have a CrashLoopBackOff
status if it has finished deployment, but it's configured to keep restarting even if the exit code is zero. For example, if you deploy a busybox image without specifying any arguments, the image starts, runs, finishes, and then restarts in a loop:
$ kubectl run nginx --image nginx
pod/nginx created
$ kubectl run busybox --image busybox
pod/busybox created
$ kubectl get pods --watch
NAME READY STATUS RESTARTS AGE
busybox 0/1 ContainerCreating 0 3s
nginx 1/1 Running 0 11s
busybox 0/1 Completed 0 3s
busybox 0/1 Completed 1 4s
busybox 0/1 CrashLoopBackOff 1 5s
$ kubectl describe pod busybox
Name: busybox
Namespace: default
Priority: 0
Node: aks-nodepool<number>-<resource-group-hash-number>-vmss<number>/<ip-address-1>
Start Time: Wed, 16 Aug 2023 09:56:19 +0000
Labels: run=busybox
Annotations: <none>
Status: Running
IP: <ip-address-2>
IPs:
IP: <ip-address-2>
Containers:
busybox:
Container ID: containerd://<64-digit-hexadecimal-value-1>
Image: busybox
Image ID: docker.io/library/busybox@sha256:<64-digit-hexadecimal-value-2>
Port: <none>
Host Port: <none>
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Wed, 16 Aug 2023 09:56:37 +0000
Finished: Wed, 16 Aug 2023 09:56:37 +0000
Ready: False
Restart Count: 2
If you don't recognize the issue after you create more pods on the node, then run a pod on a single node to determine how many resources the pod actually uses.
Third-party information disclaimer
The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, about the performance or reliability of these products.
Contact us for help
If you have questions or need help, create a support request, or ask Azure community support. You can also submit product feedback to Azure feedback community.