-
Run the following command to setup the lab.
student@bchd:~$drill logging
In namespace lincoln there is a single pod named vampire-hunter. Output the logs from this Pod but ONLY the lines that contain the word nginx. Put these lines inside a file named lincoln-logs.txt.
Weight: 4%
-
Locate the
vampire-hunterpod in your cluster. -
Retrieve the logs from the pod's container; ONLY output the lines that contain the word nginx.
-
Save this output to
lincoln-logs.txt. -
Verify the objectives were completed.
-
Locate the
nginx-configuredpod in your cluster.Click
Kubectl get has an optional flag which will look in the
lincolnnamespace. -
Retrieve the logs from the pod's container; ONLY output the lines that contain the word nginx.
Click
Sneaky questions like these require a bit of Linux know-how to do. Once you have the correct kubectl command, you'll want to filter the output in Linux by adding
| grep nginxto the end of your command. -
Save this output to
lincoln-logs.txt.Click
This is also something that requires some Linux know-how. Any command that generates output can be redirected into a file. Try these two steps and you'll see how:
echo "Peekaboo!" > testfile.txtcat testfile.txtYou'll see the string output "Peekaboo!" was written inside the file instead of being printed to the screen.
-
Verify the objectives were completed.
Click
Check the contents of the log file you copied the output to. If there are entries there, everything worked!
-
Locate the vampire-hunter pod in your cluster.
Click
-
Run the following command to confirm the pod is present.
student@bchd:~$kubectl get pod -n lincoln vampire-hunterNAME READY STATUS RESTARTS AGE vampire-hunter 1/1 Running 0 2m34s
-
-
Retrieve specific lines from the container's logs.
Click
-
Use the kubectl logs command with the appropriate bash expression.
student@bchd:~$kubectl logs -n lincoln vampire-hunter | grep nginx10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf 10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.confOnly lines containing the string "nginx" should appear!
-
-
Save the log lines to a specific file.
Click
-
Use the kubectl logs command with the appropriate bash expressions to both filter for "nginx" and save to a file.
student@bchd:~$kubectl logs -n lincoln vampire-hunter | grep nginx > lincoln-logs.txt
-
-
Verify the objectives were completed.
Click
-
Let's check out lincoln-logs.txt file to see what was copied to it.
student@bchd:~$cat lincoln-logs.txt10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf 10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
-
-
Wanna run the lab again? Run the following script to teardown your work.
student@bchd:~$teardown logging
Knowing how to troubleshoot is a skill that is essential to becoming a proficient Kubernetes Developer or Administrator.
The objective of this challenge is to fix broken stuff. To simulate this, you'll run bash scripts to run that will cause things to break!
-
Create some havoc in your cluster!
student@bchdcd && wget https://static.alta3.com/projects/k8s/havoc02.sh && bash havoc02.sh
You're competently working on your own projects when the office slacker pings you. "Hey, uh, there's something, uh, wrong inside the fail02 namespace. Can you, like, help?" You sigh, knowing you're not going to get anything else useful out of them and turn to your CLI.
Find what's wrong in the fail02 namespace and fix it!
Recommended commands:
kubectl getkubectl describekubectl edit- NEW RESOURCE OBJECT
kubectl get events
Hint #1
kubectl get pods -n fail02
Hint #2
kubectl describe pod failingpod02 -n fail02
AND/OR
kubectl get events -n fail02
Hint #3
There is a typo in the image name!
Solution
kubectl edit pod failingpod02 -n fail02
Change line 18 from nginxx to nginx

