How do you view the logs of a specific pod in Kubernetes?

Prepare for the KCNA Certification Test. Study with flashcards, multiple-choice questions, and detailed explanations to enhance your understanding of Kubernetes Cloud Native concepts. Ace your exam!

Multiple Choice

How do you view the logs of a specific pod in Kubernetes?

Explanation:
Fetching pod logs in Kubernetes is done with kubectl logs, which retrieves the stdout and stderr from the containers in a pod. If the pod has a single container, you can simply run kubectl logs <pod-name>. If there are multiple containers, you must specify which container’s logs you want with -c <container-name> (for example, kubectl logs <pod> -c <container>). You can also use options like --follow to stream logs, --timestamps to include time stamps, or --previous to view logs from a previously terminated container. The other proposed commands aren’t valid ways to view logs (they don’t exist or don’t fetch logs), which is why kubectl logs <pod-name> is the correct approach.

Fetching pod logs in Kubernetes is done with kubectl logs, which retrieves the stdout and stderr from the containers in a pod. If the pod has a single container, you can simply run kubectl logs . If there are multiple containers, you must specify which container’s logs you want with -c (for example, kubectl logs -c ). You can also use options like --follow to stream logs, --timestamps to include time stamps, or --previous to view logs from a previously terminated container. The other proposed commands aren’t valid ways to view logs (they don’t exist or don’t fetch logs), which is why kubectl logs is the correct approach.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy