kubectl logs
The kubectl command that prints what a container wrote to its standard output and standard error.
In more detail
With --previous it shows the output of the last run before a restart, which is where a crash usually explains itself. Use -c to pick one container when a pod has several. Logs only exist once a process has run, so they are empty for image pull failures.
Example
kubectl logs web --previousRelated terms
- CrashLoopBackOff — A container status meaning the container keeps exiting after it starts, so the kubelet is waiting longer and longer before restarting it.
- standard output and standard error — The two channels a program writes normal output (stdout) and error messages (stderr) to, plus stdin for input.
- kubectl exec — The kubectl command that runs a command, such as a shell, inside a running container.
Taught in
- Sidecars And Init Containers — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Jobs And CronJobs That Behave — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Monitoring With The Built-in CLI — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Container Logs — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Debugging Applications In Kubernetes — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Observability: Timed Drill And Checkpoint — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Troubleshooting: Probes, Logs, exec And CrashLoopBackOff — Kubernetes: Production-Grade Container Orchestration