Skip to main content
This lesson walks through solutions for Mock Exam 1 question by question, with reproducible manifests and verification commands. Each question includes the expected YAML or command examples, how to apply them, and how to verify the result. Table of contents

Question 1 — Create a Pod mc-pod in namespace mc with three containers and a shared non-persistent volume

Requirements
  • Pod name: mc-pod in namespace mc
  • Containers:
    • mc-pod-1: nginx:1-alpine, with env var NODE_NAME sourced from spec.nodeName
    • mc-pod-2: busybox:1, appends date to /var/log/shared/date.log every second
    • mc-pod-3: busybox:1, tails /var/log/shared/date.log
  • Shared ephemeral volume: emptyDir mounted at /var/log/shared for containers 2 and 3
A split-screen lab interface: the left pane shows a KodeKloud task describing how to create a Kubernetes Pod with three containers and shared volume, and the right pane shows a dark terminal window ready for commands.
Example manifest to create mc-pod:
Apply the manifest:
Verify logs from the tailing container (mc-pod-3) to confirm the shared emptyDir behavior:
You should see continuous timestamp lines written by mc-pod-2 and read by mc-pod-3.
emptyDir is ephemeral and exists only for the lifetime of the Pod. Use it for intra-Pod sharing (multiple containers in the same Pod). For persistent data across Pod restarts or node failures, use PersistentVolumes instead.

Question 2 — Prepare node01 by installing cri-dockerd

Task summary
  • SSH to node01 as user bob
  • Become root and install the cri-dockerd Debian package located in /root
  • Start and enable the cri-dockerd systemd service
Common command sequence:
Expected outcomes
  • dpkg -i shows the package configured and service/unit symlinks created
  • systemctl status cri-dockerd reports Active: active (running)
  • systemctl is-enabled cri-dockerd returns enabled

Question 3 — Save Vertical Pod Autoscaler CRD names to /root/vpa-crds.txt

On the control plane, list CRDs and filter for Vertical Pod Autoscaler resources. This saves the CRD names into /root/vpa-crds.txt. Efficient one-liner:
Example expected contents:

Question 4 — Create ClusterIP Service messaging-service on port 6379 (internal only)

Expose the existing Pod messaging within the cluster on port 6379. A ClusterIP service (default type) provides internal-only access. Imperative creation:
Notes
  • kubectl expose pod uses the Pod’s labels as the service selector. If the messaging Pod has no labels, the Service will have no selector (no endpoints). Add labels to the Pod or create a corresponding Endpoints object if needed.
Verify:
kubectl describe svc should show an endpoint mapping to the messaging Pod IP and port 6379 when labels and selectors match.

Question 5 — Create Deployment hr-web-app (image kodekloud/webapp-color) with 2 replicas

Create the Deployment imperatively:
Verify:
If you need a manifest for version control or review, use kubectl get deployment hr-web-app -o yaml and save it.

Question 6 — Fix the orange Pod (init container CrashLoopBackOff)

Symptom
  • orange Pod stuck in Init:CrashLoopBackOff
  • Init container init-myservice fails with exit code 127
  • Logs show: sh: sleeeep: not found — a typo.
Diagnosis and fix
  1. Export the current Pod manifest for editing:
  1. In question6.yaml, fix the init container command:
Replace the incorrect sleeeep 2; with sleep 2;:
  1. Replace the Pod with the corrected manifest (force replace since Pods are not controlled by a controller):
  1. Verify:
After the fix, the init container should complete successfully and the Pod should transition to Running.

Question 7 — Expose hr-web-app as a NodePort Service hr-web-app-service using node port 30082

Requirements
  • Service name: hr-web-app-service
  • Type: NodePort
  • Service port: 8080
  • NodePort: 30082
  • Selector: app: hr-web-app (matching the deployment pods)
Example manifest:
Apply:
Verify:
The describe output should show NodePort: 30082/TCP and endpoints that correspond to the deployment’s pods.
NodePort values must be within the cluster’s allowed NodePort range (usually 30000-32767). Ensure the chosen 30082 is available and not already in use.

Question 8 — Create a PersistentVolume pv-analytics (hostPath) with 100Mi and RWX

Specifications
  • Name: pv-analytics
  • Capacity: 100Mi
  • AccessModes: ReadWriteMany
  • hostPath: /pv/data-analytics
  • volumeMode: Filesystem
Example PV manifest:
Apply and verify:
Expected status: Available until a PersistentVolumeClaim binds to it. Note: hostPath PVs are node-local. ReadWriteMany on hostPath may not provide the same semantics across multiple nodes; use a distributed storage solution for real multi-node RWX needs.

Question 9 — Create Horizontal Pod Autoscaler webapp-hpa (CPU-based, 50% target, 300s stabilization window)

Requirements
  • Target: Deployment kk-app-deploy (default namespace)
  • minReplicas: 2
  • maxReplicas: 10
  • Target average CPU utilization: 50%
  • Scale-down stabilization window: 300 seconds
  • Use autoscaling/v2 API to set behavior
Manifest:
Apply and verify:
autoscaling/v2 requires metrics to be available (for example, metrics-server). Ensure a metrics provider is installed and returning CPU metrics for HPA to evaluate and scale the deployment.

Question 10 — Create Vertical Pod Autoscaler analytics-vpa in Auto update mode

Requirements
  • Name: analytics-vpa
  • Target: Deployment analytics-deployment in default namespace
  • Update mode: Auto (VPA may evict and recreate pods to apply new resource requests)
Manifest:
Apply and verify:
Note: VPA behavior depends on VPA admission and eviction configuration; Auto mode may cause pod restarts to adjust requests.

Question 11 — Create a Gateway resource web-gateway in namespace nginx-gateway

Specifications
  • Name: web-gateway
  • Namespace: nginx-gateway
  • gatewayClassName: nginx
  • One listener named http, protocol HTTP on port 80
Manifest example:
Apply and verify:
The Gateway should appear in the nginx-gateway namespace. If a gateway controller (nginx or other) is active, it will program the Gateway and report status.

Question 12 — Update Helm repo and upgrade the release to chart version 18.1.5

Context
  • Helm release in namespace kk-ns with name kk-mock1
  • Current chart version 18.1.0, goal: upgrade to 18.1.5
Steps:
  1. List Helm releases in the namespace:
  1. Update Helm repositories:
  1. (Optional) Search for available chart versions:
  1. Upgrade the release to the target chart version:
  1. Verify the upgrade:
After upgrading, you should see the chart version updated to nginx-18.1.5 for the kk-mock1 release.
Links and References This completes the step-by-step solutions for Mock Exam 1.

Watch Video

Practice Lab