CKAD-Certified Kubernetes Application Developer Practise Questions

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

  • 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

# 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

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

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

Answer 3

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

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

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 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

“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

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 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

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

Go to the course with this link!

Data & Cloud Architect and Trainer .