Refer to Exhibit.

Set Configuration Context:
[student@node-1] $ | kubectl
Config use-context k8s
Context
You sometimes need to observe a pod's logs, and write those logs to a file for further analysis.
Task
Please complete the following;
* Deploy the counter pod to the cluster using the provided YAMLspec file at /opt/KDOB00201/counter.yaml
* Retrieve all currently available application logs from the running pod and store them in the file /opt/KDOB0020l/log_Output.txt, which has already been created
Suggested Answer: A
Get Premium CKAD Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
31 comments · newest first
LE
Lelia
11 months ago
Seems straightforward, but I hope the logs are easy to access!
CH
Cheryl
11 months ago
Yup, and don’t forget the `-c` option for that!
LA
Lashawnda
12 months ago
Wait, do I really need to specify the container name if there are multiple?
TI
Titus
12 months ago
Totally agree, that's the way to go!
MA
Maryann
1 year ago
Just use `kubectl apply -f /opt/KDOB00201/counter.yaml` to deploy the pod!
MO
Moira
1 year ago
I'm a bit confused about the `--since` flag for logs. I think it helps filter logs by time, but I can't recall the exact usage.
PE
Pedro
1 year ago
I feel like I saw a question similar to this in our mock exams, where we had to specify the container name if there were multiple containers. I hope I remember that correctly.
RO
Rosio
1 year ago
I practiced retrieving logs before, and I believe the command is `kubectl logs > /opt/KDOB0020l/log_Output.txt`, but I might have mixed up the syntax.
JE
Jerry
1 year ago
I think I remember that we need to use `kubectl apply -f` to deploy the pod, but I'm not entirely sure about the exact path to the YAML file.
WI
Wilda
1 year ago
No problem, I've got this. I'll just follow the step-by-step instructions in the question. Deploy the pod, then use kubectl logs to capture the logs and redirect them to the output file. Easy peasy!
LI
Linsey
1 year ago
Okay, let's see here. I know I need to deploy the pod, but I'm not sure if I should use apply or create. And then for the logs, do I need to specify the container name if there's only one?
AN
Annalee
1 year ago
Hmm, I'm a bit unsure about the exact syntax for the kubectl logs command. I'll need to double-check the documentation to make sure I get the right flags and options.
MA
Margarett
1 year ago
I think I've got this! First, I'll deploy the counter pod using the YAML file, then I'll use kubectl logs to grab the logs and save them to the output file.
HE
Hershel
1 year ago
I wonder if the person who wrote this question has ever actually used Kubernetes in a real-world scenario, or if they just read about it in a book and decided to torture us all.
LE
Levi
1 year ago
Definitely, real-world application is key to truly understanding these concepts.
VI
Virgilio
1 year ago
I agree, it would be nice if they focused on practical scenarios.
HE
Hester
1 year ago
Yeah, I feel like they make it more complicated than it needs to be.
ET
Ettie
1 year ago
I know right, some of these questions can be so frustrating.
KR
Krissy
1 year ago
Wait, there's a pod called 'counter'? I bet it just increments a number every second. I wonder if I can make it count up to a million before the exam is over.
EV
Evette
1 year ago
I'm pretty sure I've used the kubectl logs command before, but I always forget the exact syntax. Hopefully, I can just copy the example and be done with it.
PA
Paris
1 year ago
If the pod has multiple containers, remember to specify the container name using the -c option.
MA
Mable
1 year ago
Don't forget to replace with the actual name of the pod.
LY
Lynette
1 year ago
Make sure to use the kubectl logs command with the -f option to stream the logs.
ST
Stephanie
2 years ago
Seriously, why do they always make us work with files in these exams? Just give me a command-line interface and let me figure it out!
DO
Doyle
1 year ago
I agree, it would be much easier to just work directly in the command line.
NO
Nobuko
1 year ago
Yeah, I wish they would focus more on practical tasks.
TW
Twanna
1 year ago
I know, dealing with files can be a hassle sometimes.
KA
Kayleigh
2 years ago
Ah, finally a question that doesn't involve writing YAML from scratch. I'll just follow the steps in the solution and hope I get it right!
CA
Caren
2 years ago
The solution provided explains how to use kubectl apply and kubectl logs commands for this task.
AN
Anastacia
2 years ago
Yes, we need to deploy the counter pod and store its logs in a file.
CA
Caren
2 years ago
I think the question is about deploying a pod and retrieving its logs.