nerdexam
Linux_Foundation

CKA · Question #43

Monitor the logs of pod bar and: • Extract log lines corresponding to error file-not-found • Write them to /opt/KUTR00101/bar

This task tests your ability to use kubectl to stream pod logs and filter specific error messages, then persist the results to a file - a common CKA/CKAD exam scenario.

Submitted by kevin_r· May 4, 2026Troubleshooting

Question

Monitor the logs of pod bar and: • Extract log lines corresponding to error file-not-found • Write them to /opt/KUTR00101/bar

Explanation

This task tests your ability to use kubectl to stream pod logs and filter specific error messages, then persist the results to a file - a common CKA/CKAD exam scenario.

Approach. Use 'kubectl logs bar' to retrieve logs from pod 'bar', then pipe through grep to filter for 'file-not-found' lines: 'kubectl logs bar | grep file-not-found > /opt/KUTR00101/bar'. If the pod has multiple containers, add '-c <container-name>'. If you need historical logs from a crashed/restarted pod, add '--previous'. The redirection operator '>' writes (overwrites) the filtered output to the destination file; use '>>' to append instead if needed.

Concept tested. kubectl log retrieval and shell redirection - specifically 'kubectl logs <pod>', grep filtering, and writing stdout to a file using shell redirection. Also tests awareness of flags like --previous and -c for multi-container pods.

Reference. https://kubernetes.io/docs/concepts/cluster-administration/logging/ - 'kubectl logs' command reference

Topics

#Log Management#Pod Troubleshooting#kubectl logs#Log Filtering

Community Discussion

No community discussion yet for this question.

Full CKA Practice