Exam KCNA All QuestionsBrowse all questions from this exam
Question 20

Which is the correct kubectl command to display logs in real time?

    Correct Answer: D

    To display logs in real time for a Kubernetes container, the correct kubectl command is 'kubectl logs -f test-container-1'. The '-f' flag stands for 'follow', which streams the log output in real-time. This allows for continuous monitoring by displaying log entries as they are generated.

Discussion
dadaarceOption: D

The -f or --follow flag is used to stream logs in real time.

phcunhaOption: D

D. kubectl logs -f test-container-1 Explanation: The -f flag in the kubectl logs command stands for "follow," which allows you to continuously stream the logs in real-time as new log entries are added. This is useful for monitoring applications or troubleshooting issues as they occur. An analogy for this command could be tuning in to a live radio broadcast. When you listen to a live radio show, you want to hear the content as it's being broadcasted, rather than just a recording of past broadcasts. Similarly, using kubectl logs -f lets you "tune in" to the ongoing activity of a container, receiving log updates in real-time.

nvtienanhOption: D

D is correct