nerdexam
Linux_Foundation

CKA · Question #1

Monitor the logs of pod foo and: Extract log lines corresponding to error unable-to-access-website Write them to /opt/KULM00201/foo

This question tests your ability to retrieve and filter Kubernetes pod logs using kubectl, then persist specific error lines to a file on the filesystem.

Submitted by tyler.j· May 4, 2026Troubleshooting

Question

Monitor the logs of pod foo and: Extract log lines corresponding to error unable-to-access-website Write them to /opt/KULM00201/foo

Explanation

This question tests your ability to retrieve and filter Kubernetes pod logs using kubectl, then persist specific error lines to a file on the filesystem.

Approach. The correct command is: kubectl logs foo | grep 'unable-to-access-website' > /opt/KULM00201/foo. First, kubectl logs foo streams all log output from the pod named 'foo'. Piping to grep 'unable-to-access-website' filters only lines containing that exact error string. The > operator redirects the filtered output to the destination file, creating it if it doesn't exist. If the pod has multiple containers, you may need to add -c <container-name>; if you want all historical logs including previous crashes, add --previous.

Concept tested. kubectl logs filtering and output redirection - a core CKA/CKAD task requiring knowledge of kubectl logs, Unix pipe/grep filtering, and file redirection to capture specific log entries for troubleshooting.

Reference. https://kubernetes.io/docs/concepts/cluster-administration/logging/ - kubectl logs official docs

Topics

#kubectl logs#log management#log filtering#output redirection

Community Discussion

No community discussion yet for this question.

Full CKA Practice