Skip to main content
In this lesson, we walk through the solutions for Lightning Lab Two. This lab consists of several tasks designed to help you troubleshoot pods, update their configurations, create a CronJob, deploy a pod with custom parameters, set up an Ingress resource for virtual hosting routing, and inspect logs for warning messages.

Task 1: Identify and Troubleshoot the Problematic Pod

First, identify which pod is not in a “Ready” state. Several pods are deployed across various namespaces. Run the following command to list all pods:
You will see output similar to this:
Inspect the problematic pod—identified here as nginx1401 in the dev1401 namespace—by running:
Examine the events section for clues. In this example, the events indicate that the readiness probe has failed, suggesting a misconfiguration. Next, extract the pod configuration to a YAML file for further inspection:
Review the configuration, which includes probe settings. A snippet from the YAML output might look like this:
Notice that although the readiness probe is set to check port 8080, other parts of the configuration might be expecting port 9080. To correct the inconsistency, update the configuration as follows:
Apply the updated configuration by replacing the existing pod. Save the file (for example, as nginx1401.yaml) and then run:
Finally, verify that the pod is now in a ready state:
Ensure your pod configuration settings (such as containerPort) match across all probe definitions to avoid inconsistencies.

Task 2: Create a CronJob Named “dice”

The next task involves creating a CronJob called “dice” that runs every minute. This job leverages the kodekloud/throw-dice image, which randomly returns a number between one and six. A roll of six indicates success; any other result is a failure. Additional requirements for the CronJob include:
  • Running jobs non-parallel (in series).
  • Completing the task only once (completions: 1).
  • Using a backoff limit of 25.
  • Terminating the job if it runs longer than 20 seconds (using activeDeadlineSeconds: 20).
  • Setting the restart policy to Never.
Create the CronJob definition in a file called dice-job.yaml:
Save and apply the CronJob configuration:
Verify the CronJob by running:
You should see an output similar to:

Task 3: Create a “my-busybox” Pod in a Specific Namespace

In this task, you will create a pod named “my-busybox” using the busybox image in the dev2406 namespace. The pod requirements are as follows:
  • The container inside the pod should be named secret and execute sleep 3600.
  • Mount a read-only secret volume named secret-volume at /etc/secret-volume. (The secret dotfile-secret is pre-created.)
  • Schedule the pod on the control plane by specifying nodeName: controlplane.
Start by generating a basic pod manifest using dry-run:
Edit the generated my-busybox.yaml file to include the required customizations:
Apply the configuration with:

Task 4: Create an Ingress Resource for Virtual Hosting Routing

This task involves creating a single Ingress resource named ingress-vh-routing to handle virtual hosting routing for HTTP traffic. The configuration will route traffic as follows:
  • Requests to watch.ecom-store.com with the path /video will be directed to the video-service on port 8080.
  • Requests to apparels.ecom-store.com with the path /wear will be directed to the apparels-service on port 8080.
Create a file named ingress.yaml with the following content:
Apply the Ingress resource:
Verify that the Ingress resource is successfully created with:
For more details on configuring Ingress resources, visit Ingress in Kubernetes.

Task 5: Inspect Pod Logs and Redirect Warnings

For the final task, inspect the logs of a pod in the default namespace that contains a container named log-x. Your goal is to redirect any warning messages to a file located at /opt/warnings.log on the control plane node. First, list the pods to identify the target pod:
Assuming the pod identified is dev-pod-dind-878516, execute the following command to filter and redirect warning messages:
To verify the log output, inspect the file:
Make sure you have the necessary permissions to write to /opt/ on the control plane node.

This concludes all tasks for Lightning Lab Two. Follow each step carefully to ensure proper configuration and successful task completion. Happy Kubernetes troubleshooting! For more Kubernetes tips and documentation, check out the Kubernetes Documentation.

Watch Video