Skip to content

Latest commit

 

History

History
194 lines (109 loc) · 5.25 KB

File metadata and controls

194 lines (109 loc) · 5.25 KB

TASK 1- Container Logging

Lab Setup

  1. Run the following command to setup the lab.

    student@bchd:~$ drill logging

Summary

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%

Tasks

  1. Locate the vampire-hunter pod in your cluster.

  2. Retrieve the logs from the pod's container; ONLY output the lines that contain the word nginx.

  3. Save this output to lincoln-logs.txt.

  4. Verify the objectives were completed.

Hints

  1. Locate the nginx-configured pod in your cluster.

    Click

    Kubectl get has an optional flag which will look in the lincoln namespace.

  2. 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 nginx to the end of your command.

  3. 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.txt

    cat testfile.txt

    You'll see the string output "Peekaboo!" was written inside the file instead of being printed to the screen.

  4. 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!

Answers

  1. Locate the vampire-hunter pod in your cluster.

    Click
    1. Run the following command to confirm the pod is present.

      student@bchd:~$ kubectl get pod -n lincoln vampire-hunter

      NAME             READY   STATUS    RESTARTS   AGE
      vampire-hunter   1/1     Running   0          2m34s
      
  2. Retrieve specific lines from the container's logs.

    Click
    1. Use the kubectl logs command with the appropriate bash expression.

      student@bchd:~$ kubectl logs -n lincoln vampire-hunter | grep nginx

      10-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
      

      Only lines containing the string "nginx" should appear!

  3. Save the log lines to a specific file.

    Click
    1. 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

  4. Verify the objectives were completed.

    Click
    1. Let's check out lincoln-logs.txt file to see what was copied to it.

      student@bchd:~$ cat lincoln-logs.txt

      10-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
      

Lab Teardown

  1. Wanna run the lab again? Run the following script to teardown your work.

    student@bchd:~$ teardown logging

Task 2- Troubleshooting

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!

SETUP

  1. Create some havoc in your cluster!

    student@bchd cd && wget https://static.alta3.com/projects/k8s/havoc02.sh && bash havoc02.sh

SCENARIO

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 get
  • kubectl describe
  • kubectl 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