Bird
0
0

You want to monitor logs of a pod named webserver continuously but only for the container named nginx. Which command should you use?

hard📝 Best Practice Q15 of 15
Kubernetes - Pods
You want to monitor logs of a pod named webserver continuously but only for the container named nginx. Which command should you use?
Akubectl logs webserver --container nginx
Bkubectl describe pod webserver -c nginx --follow
Ckubectl logs webserver -c nginx --follow
Dkubectl logs webserver --tail=0
Step-by-Step Solution
Solution:
  1. Step 1: Identify the need to specify container and follow logs

    To monitor logs continuously, use --follow. For multi-container pods, specify container with -c <container-name>.
  2. Step 2: Match the correct command syntax

    kubectl logs webserver -c nginx --follow correctly specifies container and streams logs live.
  3. Final Answer:

    kubectl logs webserver -c nginx --follow -> Option C
  4. Quick Check:

    Use '-c' for container and '--follow' to stream logs [OK]
Quick Trick: Use '-c container --follow' to stream specific container logs live [OK]
Common Mistakes:
  • Using 'describe' instead of 'logs' to view logs
  • Using '--container' instead of '-c' which is invalid
  • Using '--tail=0' which shows no logs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes