Skip to main content
In this guide, we will walk you through solving a Kubernetes mock exam with step-by-step instructions on creating deployments, services, configuring taints, tolerations, node affinity, ingress resources, readiness and liveness probes, jobs, multi-container pods, and persistent volumes. Follow along to apply these configurations in your Kubernetes environment.

1. Create a Deployment and Expose It as a NodePort Service

Creating the Deployment

First, create a deployment named my-webapp with the following parameters:
  • Image: nginx
  • Replicas: 2
  • Label: tier=front end (as implied)
Generate a YAML configuration using a dry run and save it to my-webapp.yaml:
Review the file if necessary, then apply the configuration:
Verify the deployment:

Exposing the Deployment as a Service

Next, expose the my-webapp deployment as a NodePort service with these settings:
  • Service Name: front-end-service
  • Service Type: NodePort
  • Port: 80
  • Node Port: 30083 (to be set manually in the YAML)
Generate the service configuration using a dry run:
Open front-end-service.yaml and add the node port configuration (30083) under the appropriate section. Then, apply the updated configuration:
Verify the service:
The image shows a KodeKloud mock exam interface with a task to create a Kubernetes deployment and NodePort service using specific parameters.

2. Add a Taint to a Node and Create a Pod with a Toleration

Tainting the Node

Check the nodes in your cluster:
Apply a taint on the node named node01 with key app_type, value alpha, and effect NoSchedule:
Confirm the taint by describing the node:

Creating the Pod with Toleration

Create a pod named alpha using the redis image. First, generate the pod’s YAML configuration:
Edit the alpha.yaml file to include the following toleration under the pod spec:
A complete sample configuration should look like this:
Apply the configuration:
Verify that the pod is running on node01:
The image shows a KodeKloud mock exam task to add a taint to a Kubernetes node and create a pod with specific toleration.

3. Label the Control Plane Node and Create a Deployment with Node Affinity

Labeling the Node

List your nodes to find the control plane node:
Label the control plane node (assumed to be named controlplane) with app_type=beta:
Confirm the label is applied:

Creating the Beta-Apps Deployment with Node Affinity

Create a deployment named beta-apps with the following settings:
  • Image: nginx
  • Replicas: 3
Generate the YAML configuration:
Edit the file to add a node affinity section under the pod spec:
A complete version of the edited deployment YAML will be:
Apply the deployment:
Verify that the pods are scheduled on the control plane node:

4. Create an Ingress Resource for the My-Video Service

First, verify the my-video-service details (it listens on port 8080):
You should see output similar to:
Create an ingress resource so that my-video-service is reachable via the URL ckad-mock-exam-solution.com at the path /video. Generate the ingress configuration imperatively:
Then, adjust the YAML to ensure it follows the proper format. The final configuration should be:
Apply the ingress resource:
Verify the ingress configuration:
The image shows a KodeKloud mock exam task to create an Ingress Resource for a service, with a terminal ready for input.

5. Update a Pod with a Readiness Probe

Update a pod (named pod-with-rprobe) to include a readiness probe. First, retrieve its current configuration:
Edit pod.yaml and insert the following snippet under the container spec (before the ports section):
An updated container section should resemble:
After saving your changes, force replace the existing pod:
Verify the update:

6. Create a Pod with a Liveness Probe

Create a new pod named nginx1401 in the default namespace using the nginx image. This pod will have a liveness probe that executes a command to check /var/www/html/probe. The probe has an initial delay of 10 seconds and executes every 60 seconds. Create a file called nginx1401.yaml with the following content:
Apply the configuration:
If validation errors occur, verify the YAML formatting and ensure the liveness probe is directly placed under the container.
The image shows a KodeKloud mock exam task to create a Kubernetes pod with a liveness probe using the nginx image.

7. Create a Job Called Whalesay

Create a Kubernetes Job named whalesay using the docker/whalesay image. This job will execute a command to display “I am going to ace CKAD!”, with 10 completions, a backoff limit of 6, and a restart policy set to Never. Generate the job configuration using a dry run:
Edit the whalesay.yaml file to include the completions and backoffLimit fields. The finalized YAML should be:
Apply the job configuration:
Monitor the job progress until all 10 completions succeed:
The image shows a KodeKloud mock exam task to create a Kubernetes job named "whalesay" using a specific Docker image and command, with defined completions and backoff limits.

8. Create a Multi-Container Pod

Create a pod named multi-pod containing two containers with the configurations below:
  • Container 1:
    • Name: jupiter
    • Image: nginx
    • Environment Variable: type=planet
  • Container 2:
    • Name: europa
    • Image: busybox
    • Command: /bin/sh -c "sleep 4800"
    • Environment Variable: type=moon
Create a file called multi-pod.yaml with the following content:
Apply the configuration:

9. Create a Persistent Volume

Create a persistent volume named custom-volume with these attributes:
  • Storage: 50Mi
  • Reclaim Policy: Retain
  • Access Modes: ReadWriteMany
  • Host Path: /opt/data
Create a file named pv.yaml with the configuration below:
Apply the persistent volume configuration:
The image shows a KodeKloud mock exam task to create a Kubernetes PersistentVolume named "custom-volume" with specific attributes, alongside a terminal interface.

This concludes the mock exam solutions. Verify each resource with the appropriate kubectl commands to ensure all configurations are applied successfully. Enjoy scaling your Kubernetes expertise!

Watch Video