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.
Question
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
Community Discussion
No community discussion yet for this question.