This lesson provides detailed solutions for each question in Mock Exam Three, focusing on specific Kubernetes tasks with clear instructions and code examples.
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:
Do not include a numeric priority field.Replace the pod if needed:
Copy
Ask AI
kubectl replace -f question5-pod.yaml --force# If an error appears about a numeric priority, remove any "priority: 0" specification and apply again:kubectl apply -f question5-pod.yaml
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:
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:
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:
Copy
Ask AI
https://controlplane:9999
Since the kube-apiserver listens on port 6443, update the kubeconfig file as follows:
If the deployment still shows one available replica, review the deployment events:
Copy
Ask AI
kubectl describe deployment nginx-deploy
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):
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):