Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Terminal output
RESTARTS says 12, but your Pod never moved. Look at the name, x2kqp, and the age, three hours. A Pod is a small wrapper around your containers, and this one is still the same Pod. So what exactly did Kubernetes restart twelve times?
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
api-7d9f8c6b5-x2kqp 1/1 Running 12 3hRestart keeps the name. Replacement changes it.
RESTARTS counts how often the container, the running program inside the Pod, was swapped for a fresh one. On the left, the same Pod stays on node-1 while the counter climbs to 12. On the right, a replaced Pod gets a new name, m4ntz, and starts at 0.
Read why the last container stopped
Run kubectl logs on x2kqp with the --previous flag. That prints the output of the container that crashed, not the fresh one. Here, the illustrative error says DATABASE_URL is not set, so the app exits with code 1 and restarts. If logs look clean, check kubectl describe for memory kills.
$ kubectl logs api-7d9f8c6b5-x2kqp --previous
Error: DATABASE_URL is not set
process exited with code 1Same Pod, same name, new container every time.
Same Pod, same name, new container every time. When restarts climb, run kubectl logs --previous first, and read why the last container stopped.
