CKAD-Certified Kubernetes Application Developer Practise Questions

Serkan SAKINMAZ
6 min readMay 15, 2021

Kubernetes Application Developer exam is one of the challengeable assessment, it is different from other exams since you need to implement real configurations instead of selecting A,B,C,D.

In this section, I am going to give you some exam preparation questions and answers for CKAD-Certified Kubernetes Application Developer. In order to run them, you can use minikube on your local computer.

Question 1

In the default namespace, which of the following command help you to identify the top memory consuming pod?

  • kubectl top pod
  • kubectl exec pod
  • kubectl logs pod
  • kubectl get pods -o wide

Answer 1

Once you run the command at the below, it shows the metrics for the pods

kubectl top pods

Question 2

Prerequisite : Please run the pod before starting to the question :

# Run this command if you are working in minikube
# This command allows you to create a nginx pod
kubectl run nginx --image=nginx

Create a service for nginx pod which serves on port 80 and the type should be NodePort. The service name should be nginx-service

Answer 2

First of all make sure the pod is running

kubectl get pod

Expose the pod with kubectl command

kubectl expose pod nginx --port=80 --type=NodePort --name=nginx-service

You can check whether the service is created

kubectl get service nginx-service

Question 3

Question : Create a pod with the requirements at the below and copy pod details as a json to the output.json file

  • pod name : static-web
  • image: nginx
  • container port : 80
  • label : output:json

Answer 3

Steps to meet with this requirement :

Step 1-First of all create the pod with the following yaml

apiVersion: v1
kind: Pod
metadata:
name: static-web
labels:
output: json
spec:
containers:
- name: web
image: nginx
ports:
- name: web
containerPort: 80
protocol: TCP

Step 2-Save this file as a output.yaml

Step 3-Execute below command to run the pod

kubectl apply -f output.yaml

4 — Check whether the pod is running

kubectl get pod

5 — Run the following command to store pod details as a json format

kubectl get pod static-web -o json > output.json

Question 4

For this question, you might need to ask to switch to another note. Please keep in mind as well

Question : Create PersistentVolume, PersistentVolumeClaim and Pod with the following requirements

Pod details

pod name : task-pv-pod
container name : task-pv-container
image :nginx
mountPath : "/usr/share/nginx/html"
Request the following PersistentVolumeClaim

Volume Details

volume name: task-pv-volume
storage class name: manual
accessModes: ReadWriteMany
storage: 10Gi
path: "/opt/data"

Claim details

name: task-pv-claim
storage: 3Gi

Answer 4

Explanation

Step 1 -In that kind of question, you can go to “Configure a Pod to Use a PersistentVolume for Storage” from kubernetes.io documentation

Step 2-Please define pod, volume, claim in the same yaml file in order to save the time

apiVersion: v1
kind: PersistentVolume
metadata:
name: task-pv-volume
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/opt/data"
---apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: task-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 3Gi
---apiVersion: v1
kind: Pod
metadata:
name: task-pv-pod
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim
containers:
- name: task-pv-container
image: nginx
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: task-pv-storage

Step 3- Save the file and execute it

kubectl apply -f pod_volume.yaml

Step 4-See the volume, claim pod is created

Step 5 -Check whether the volume is tied to claim

kubectl get pv task-pv-volume

Question 5

Find the issue in the following deployment file. Make the required changes in the file , deploy it afterwards

# Find the issue in the deployment file
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: ngimx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80

Answer 5

When you run the deployment, you will able to see the following error

“selector” does not match template labels

The error is on label

template:
metadata:
labels:
app: ngimx

Once you correct it , you can deploy again

Label should be nginx

template:
metadata:
labels:
app: nginx

Question 6

Prerequisite : Please deploy the following deployment for that question

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80

Question : In the nginx-deployment, please make a required configuration that specifies the maximum 2 Pods that can be unavailable during the update process.

.spec.strategy.rollingUpdate.maxUnavailable is an optional field that specifies the maximum number of Pods that can be unavailable during the update process. !!!!

Answer 6

Step 1 — Deploy the provided yaml in the question

Step 2 — In order to make an update in the deployment, execute this comment

kubectl edit deployment nginx-deployment

Max Unavailable

.spec.strategy.rollingUpdate.maxUnavailable is an optional field that specifies the maximum number of Pods that can be unavailable during the update process. The value can be an absolute number (for example, 5) or a percentage of desired Pods (for example, 10%).

Step 3 — Change the .spec.strategy.rollingUpdate.maxUnavailable field in the deployment

As-is

To-be

After the change, save the file

You should see the file is edited

Question 7

Prerequisite : Create a deployment with the following yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80

Questions : For the nginx-deployment , please update image with nginx:1.16.1 version. After the rollout is successfully finished, please rollout undo the image with previous version

Do you want more questions like this ?

Certified Kubernetes Application Developer (CKAD) Test

3 tests with 57 hands-on exam questions in order to prepare Certified Kubernetes Application Developer (CKAD) exam

Go to the course with this link!

--

--