To get the logs of a specific Pod in Kubernetes, you can use the following command:
kubectl logs <pod-name>
Example:
If your Pod is named nginx-pod, you would run:
kubectl logs nginx-pod
Additional Options:
-
For a specific container (if the Pod has multiple containers):
kubectl logs <pod-name> -c <container-name> -
To follow the logs in real-time:
kubectl logs -f <pod-name> -
To get logs from a previous instance of a container:
kubectl logs <pod-name> --previous
These commands help you monitor and troubleshoot your applications running in Pods. If you want to dive deeper into logging practices, consider checking out relevant LabEx labs!
