Skip to main content
In this article, we walk through the solutions for Mock Exam 1. Each section corresponds to a specific exam question and includes a technical diagram with its original description. Follow the steps carefully to complete each task.

Question 1 – Create a Pod with Three Containers

You must create a pod named mc-pod in the MC namespace that includes three containers. You can either consult the documentation for an example pod configuration or use an imperative command with kubectl run and then modify the generated YAML file.
The image shows a task description for creating a Kubernetes Pod with three containers, each with specific requirements, alongside a terminal window for command input.
Below is an example of using kubectl run with the --overrides flag to add container definitions. The --dry-run=client flag outputs the YAML for further editing:
Alternatively, you can generate a base YAML file:
After generating the file, update it as follows:
  1. Rename the pod: Change its name to mc-pod (and remove unnecessary labels and creation timestamps).
  2. Update the first container: Rename it to mc-pod-1 and inject an environment variable (NODE_NAME) whose value is dynamically set from the spec.nodeName field. The YAML snippet becomes:
  3. Define the second container: Use the busybox:1 image with the following command:
  4. Define the third container: Use the busybox:1 image to tail the shared log file:
  5. Add a shared volume: Since containers 2 and 3 need to share the same filesystem, add a non-persistent volume using emptyDir and mount it on /var/log/shared for both containers. The final YAML is:
After saving and applying this configuration, verify the pod’s status and check the logs of container mc-pod-3. Its output should display the continuously appended date entries from container mc-pod-2.
The image shows a Kubernetes task description on the left, detailing the creation of a pod with three containers, and a terminal on the right displaying a continuous log of date and time entries.

Question 2 – Prepare Node One for Kubernetes

For this task, you will perform several actions on node one.
  1. SSH into node one using the provided credentials:
  2. Switch to the root user (if necessary):
  3. Navigate to the /root directory and locate the CRI Docker package (e.g., cri-docker_0.3.16.3-0.debian.deb).
  4. Install the CRI Docker package:
  5. Start the CRI Docker service:
  6. Verify the service status:
  7. Enable the service to start on boot:
Ensure that the service is active (running) and enabled.
If you encounter any issues with the service, recheck the installation and confirm your package file’s integrity.

Question 3 – Save Vertical Pod Autoscaler CRDs

On the control plane node, list all Custom Resource Definitions (CRDs) related to the Vertical Pod Autoscaler and save their names to /root/vpa-crds.txt.
  1. Retrieve all CRDs and filter for “vertical”:
    Expected output:
  2. Save the CRD names to a file named /root/vpa-crds.txt. The file should include:
No further modifications are required.

Question 4 – Create a Service for the Messaging Application

Expose the messaging application by creating a service named messaging-service on port 6379 within the cluster.
  1. Verify that the messaging pod is running:
  2. Expose the messaging pod:
  3. Confirm the service creation by describing it:
The output should list the service as a ClusterIP service on port 6379 with endpoints matching the messaging pod’s IP.

Question 5 – Create a Deployment for the HR Web Application

Create a deployment named hr-web-app using the image kodekloud/webapp-color with two replicas.
  1. Run the following command:
  2. Verify the deployment status:
Ensure that both replicas become available.

Question 6 – Fix the Faulty Init Container in the Orange Pod

The pod named orange is failing because its init container is crashing with exit code 127 due to a typo in the command (sleeep instead of sleep).
  1. Inspect the pod logs to identify the error:
    Expected error output:
  2. Retrieve the pod configuration and save it to a file:
  3. Edit the file question6.yaml to correct the command in the init container. Modify the snippet to:
  4. Force update the pod with the corrected configuration:
  5. Verify the pod status to ensure it transitions to a running state and the init container completes successfully.

Question 7 – Expose HR Web App via a NodePort Service

Expose the hr-web-app deployment as a service named hr-web-app-service to make it accessible on port 30082 from the nodes. Note that the web application listens internally on port 8080.
  1. Generate a NodePort service configuration with dry-run:
  2. Edit question7.yaml to include the nodePort: 30082 under the ports section as shown below:
  3. Apply the updated service configuration:
  4. Verify the service details:

Question 8 – Create a Persistent Volume

Create a persistent volume named pv-analytics with the following specifications:
  • Capacity: 100Mi
  • Access Mode: ReadWriteMany
  • Type: hostPath using the directory /pv/data-analytics
  1. Create a YAML file (e.g., question8.yaml) with the following content:
  2. Apply the configuration:
  3. Verify that the persistent volume is available:

Question 9 – Create a Horizontal Pod Autoscaler (HPA)

Create an HPA for the deployment kkapp-deploy in the default namespace with the following configuration:
  • CPU Utilization: Maintain an average of 50%
  • Replicas: Scale between 2 and 10 pods
  • Stabilization Window: 300 seconds when scaling down
  1. Prepare a YAML file (e.g., webapp-hpa.yaml) with this content:
  2. Apply the HPA configuration:
  3. Check the HPA status:

Question 10 – Create a Vertical Pod Autoscaler (VPA)

Create a Vertical Pod Autoscaler that automatically adjusts CPU and memory requests for the deployment analytics-deployment in the default namespace. The VPA should run in auto mode.
  1. Create a YAML file (e.g., question10.yaml) with the following content:
  2. Apply the VPA configuration:
  3. Verify that the VPA has been created:

Question 11 – Create a Kubernetes Gateway Resource

Create a Gateway resource for the web application.
  1. Create a YAML file (e.g., question11.yaml) with the following content:
  2. Apply the gateway configuration:
  3. Verify that the Gateway resource is available in the nginx-gateway namespace:

Question 12 – Update a Helm Chart Deployment

A coworker deployed an NGINX Helm chart called kk-dash-mock-one in the kk-dash-ns namespace. An update to the chart is available, and you need to update the Helm repository and upgrade the release to version 18.1.15.
  1. List the current Helm releases in the concerned namespace:
  2. Check your chart repositories:
  3. Update all repositories to fetch the latest chart versions:
  4. Search the repository for available versions of the NGINX chart:
  5. Upgrade the release with the specified chart version:
  6. Verify the upgrade by listing the release again:

By following these detailed steps and verifying each component with the respective kubectl and helm commands, you will successfully complete all the tasks for Mock Exam 1.

Watch Video