What it means
The container starts, exits (or is killed), and the kubelet restarts it with a growing delay: 10 s, 20 s, 40 s, up to five minutes. CrashLoopBackOff is the waiting state between attempts, not the cause. The cause is in the last run's logs and exit code.
Causes and fixes
Most likely first. Run the check, and if it matches, apply the fix.
1. The application exits with an error at start-up (a missing setting, a bad config file, a database it can't reach)
Check:
kubectl logs <pod> --previous
kubectl describe pod <pod> # Last State: Terminated, Exit Code
Fix: Fix the configuration the logs complain about, then let the Deployment roll out again.
2. The container is OOMKilled (exit code 137) because it hits its memory limit
Check:
kubectl describe pod <pod> | grep -A3 'Last State'
Fix: Raise the memory limit with headroom above real usage, or fix the memory leak.
3. A liveness probe kills it before it has started, or checks something that fails
Check:
kubectl describe pod <pod> | grep -i -A2 liveness
Fix: Add a startupProbe or raise initialDelaySeconds; make the liveness check only "is this process stuck?".
4. The command finishes and exits 0, but the Pod's restartPolicy is Always (a script, not a server)
Check:
kubectl get pod <pod> -o jsonpath='{.spec.containers[0].command}'
Fix: Run it as a Job, or give the container a long-running command.
Fix it yourself
A live machine in your browser with this problem already on it. The grader checks the result.
Open the labNo account needed for your first tries.
Related errors
- OOMKilled (exit code 137)
The container used more memory than its limit and the kernel killed it.
- Liveness probe failed ... Container will be restarted
The kubelet restarts a container whose liveness probe fails, often before a slow app has started.
- CreateContainerConfigError: configmap not found
The container can't be created because a ConfigMap, Secret or key it references doesn't exist.