Skip to main content
This lesson presents detailed solutions for each question in Mock Exam Three. Each solution focuses on a specific Kubernetes task and provides clear instructions, configuration code blocks, and diagram references. All image links and descriptions remain exactly as provided.

Question 1 – Adjusting Network Parameters for Kubernetes

To deploy a Kubernetes cluster using kubeadm, you must enable IPv4 packet forwarding and ensure the settings persist across reboots. Refer to the kubeadm documentation for guidance when provisioning a new cluster.
Searching for “kubeadm” in the docs will help you locate the bootstrapping guide.
Navigate through the following path: Production Environment → Installing Kubernetes Deployment Tools → Bootstrapping a Cluster → Creating a Cluster with kubeadm.
The first step is to set up a container runtime and enable IPv4 packet forwarding using these commands:
For additional persistence, use this command if provided:
Always copy the exact command names from the exam instructions to avoid errors.
This completes Question 1.

Question 2 – Creating a Service Account and Granting PVC Listing Permissions

In this question you will:
  1. Create a service account named pvviewer.
  2. Create a cluster role (pvviewer-role) that grants permission to list persistent volumes.
  3. Bind the role to the service account with a cluster role binding (pvviewer-role-binding).
  4. Launch a pod (pvviewer) using the Redis image in the default namespace.

Step 1: Create the Service Account

Expected output:

Step 2: Create the Cluster Role

Create the role with the required permission:
Verify with:
Expected output snippet:

Step 3: Bind the Role to the Service Account

Step 4: Launch the Pod

Create a pod manifest (e.g., question2.yaml):
Apply the manifest:
Verify the pod and its service account:
This completes Question 2.

Question 3 – Creating a Storage Class

Create a storage class called rancher-sc with these settings:
  • Provisioner: rancher.io/local-path
  • Allow volume expansion: true
  • Volume binding mode: WaitForFirstConsumer
Example manifest (question3.yaml):
Apply the storage class:
This completes Question 3.

Question 4 – Configuring a ConfigMap and Updating a Deployment

In the cm-namespace, perform these tasks:
  1. Create a ConfigMap app-config containing key-value pairs such as ENV=production and LOG_LEVEL=info.
  2. Update the existing deployment cm-web-app to source environment variables from the ConfigMap.

Step 1: Create the ConfigMap

Verify with:

Step 2: Update the Deployment

Edit the deployment to include the ConfigMap:
Add the following under the container section:
After saving, verify that new pods include the environment variables from app-config. This completes Question 4.

Question 5 – Configuring Priority Classes and Pod Priority

For this task, you need to:
  1. Create a PriorityClass low-priority with a value of 50,000.
  2. Modify the existing pod lp-pod (in the low-priority namespace) to reference this PriorityClass.
  3. Recreate the pod so that it picks up the new priority without manually setting a numeric value.

Step 1: Create the PriorityClass

Create a manifest (e.g., question5.yaml):
Apply it:

Step 2: Update the Pod Manifest

Create or edit the pod manifest (e.g., question5-pod.yaml) to include only the PriorityClass name:
Do not include a numeric priority field. Replace the pod if needed:
Finally, verify the pod:
This completes Question 5.

Question 6 – Fixing Incoming Connection Issues with a Network Policy

A pod (np-test-1) and its service (np-test-service) are not receiving incoming traffic on port 80. Create a NetworkPolicy named test-network-policy to allow TCP traffic on port 80. First, confirm the pod’s labels:
Then, create a manifest (e.g., question6.yaml):
Apply the policy:
This policy permits incoming TCP traffic on port 80 for pods labeled run=np-test-1.

Question 7 – Tainting a Node and Creating Pods with Tolerations

In this question, you will:
  1. Taint a worker node (node01) with env_type=production:NoSchedule.
  2. Create a pod (dev-redis) without tolerations so it avoids node01.
  3. Create another pod (prod-redis) with a toleration to allow scheduling on node01.

Step 1: Taint the Node

Verify the taint:

Step 2: Create the Non-Tolerant Pod

Using an imperative command:

Step 3: Create the Tolerant Pod

Create a manifest (e.g., question7.yaml):
Apply it:
Finally, check that prod-redis is scheduled on node01 while dev-redis is not:

Question 8 – Binding a PVC to a PV by Matching Access Modes

A PersistentVolumeClaim (app-pvc) in the storage-ns namespace is not binding with the PersistentVolume (app-pv) because the PVC requests ReadWriteMany and the PV provides ReadWriteOnce. Update the PVC to request ["ReadWriteOnce"] as the access mode. After modifying the PVC manifest, remove the old PVC and apply the corrected file:
Verify the binding:
The PVC should now be Bound to the PV.

Question 9 – Troubleshooting a Faulty Kubeconfig File

The kubeconfig file super.kubeconfig (located at /root/CKA/super.kubeconfig) is returning a “connection refused” error. The issue is found in the cluster section where the server is set to:
Since the kube-apiserver listens on port 6443, update the kubeconfig file as follows:
After saving the changes, test the connection:
The connection should now work without errors.

Question 10 – Scaling a Deployment

The nginx-deploy deployment currently has 1 replica. To scale it to 3 replicas:
  1. Check the current status:
  2. Scale the deployment:
  3. Verify the change:
If the deployment still shows one available replica, review the deployment events:
Troubleshoot any issues such as ReplicaSet misconfigurations or control plane component errors (for example, verify the kube-controller-manager manifest at /etc/kubernetes/manifests/kube-controller-manager.yaml). This completes Question 10.

Question 11 – Creating a Horizontal Pod Autoscaler (HPA) with Custom Metric

For the api-deployment in the api namespace, create an HPA that scales based on a custom pod metric (requests_per_second), targeting an average value of 1000 with a range of 1 to 20 pods. Create a manifest (e.g., question11.yaml):
Apply the HPA:
Verify its configuration:
This completes Question 11.

Question 12 – Configuring an HTTPRoute to Split Traffic

To distribute incoming web traffic, configure an HTTP route to split between web-service (80%) and web-service-v2 (20%). The associated web gateway and services already exist. Create an HTTPRoute manifest (e.g., question12.yaml):
Apply the route:
This successfully routes 80% of traffic to web-service and 20% to web-service-v2.

Question 13 – Upgrading an Application Using Helm

You need to upgrade an application using a Helm chart from the directory /root/new-version. Follow these steps:
  1. Validate the Chart:
    Expected message:
  2. Install the Chart: Use an auto-generated name:
    List the releases:
  3. Uninstall the Old Version: Replace <old-release-name> with the actual release name:
Verify the installation:
This completes Question 13.

Question 14 – Outputting the Pod CIDR Network

To determine the pod CIDR network of the cluster and save it to /root/pod-cidr.txt, extract the podCIDR from one of the nodes:
Verify the file content:
Expected output (example):
This completes Question 14 and wraps up the mock exam solutions.
End of Lesson.

Watch Video