Linux Foundation Certified Kubernetes Administrator (CKA) Program (CKA) Free Practice Test
Question 1
Score: 4%

Task
Scale the deployment presentation to 6 pods.

Task
Scale the deployment presentation to 6 pods.
Correct Answer:
Solution:
kubectl get deployment
kubectl scale deployment.apps/presentation --replicas=6
kubectl get deployment
kubectl scale deployment.apps/presentation --replicas=6
Question 2
Get IP address of the pod - "nginx-dev"
Correct Answer:
Kubect1 get po -o wide
Using JsonPath
kubect1 get pods -o=jsonpath='{range
items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'
Using JsonPath
kubect1 get pods -o=jsonpath='{range
items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'
Question 3
From the pod label name=cpu-utilizer, find pods running high CPU workloads and write the name of the pod consuming most CPU to the file /opt/KUTR00102/KUTR00102.txt (which already exists).
Correct Answer:


Question 4
Monitor the logs of pod foo and:
* Extract log lines corresponding to error
unable-to-access-website
* Write them to/opt/KULM00201/foo

* Extract log lines corresponding to error
unable-to-access-website
* Write them to/opt/KULM00201/foo

Correct Answer:


Step 0: Set the correct Kubernetes context
If you're given a specific context (k8s in this case), you must switch to it:
kubectl config use-context k8s
## Skipping this can cause you to work in the wrong cluster/namespace and cost you marks.
Step 1: Identify the namespace of the pod foo
First, check if foo is running in a specific namespace or in the default namespace.
kubectl get pods --all-namespaces | grep foo
Assume the pod is in the default namespace if no namespace is mentioned.
Step 2: Confirm pod foo exists and is running
kubectl get pod foo
You should get output similar to:
NAME READY STATUS RESTARTS AGE
foo 1/1 Running 0 1h
If the pod is not running, logs may not be available.
Step 3: View logs and filter specific error lines
We're looking for log lines that contain:
unable-to-access-website
Command:
kubectl logs foo | grep "unable-to-access-website"
Step 4: Write the filtered log lines to a file
Redirect the output to the required path:
kubectl logs foo | grep "unable-to-access-website" > /opt/KULM00201/foo
# This creates or overwrites the file /opt/KULM00201/foo with the filtered logs.
# You may need sudo if /opt requires elevated permissions. But in most exam environments, you're already the root or privileged user.
Step 5: Verify the output file (optional but smart)
Check that the file was created and has the correct content:
cat /opt/KULM00201/foo
# Final Answer Summary:
kubectl config use-context k8s
kubectl logs foo | grep "unable-to-access-website" > /opt/KULM00201/foo
Question 5
Score:7%

Task
Create a new PersistentVolumeClaim
* Name: pv-volume
* Class: csi-hostpath-sc
* Capacity: 10Mi
Create a new Pod which mounts the PersistentVolumeClaim as a volume:
* Name: web-server
* Image: nginx
* Mount path: /usr/share/nginx/html
Configure the new Pod to have ReadWriteOnce access on the volume.
Finally, using kubectl edit or kubectl patch expand the PersistentVolumeClaim to a capacity of 70Mi and record that change.

Task
Create a new PersistentVolumeClaim
* Name: pv-volume
* Class: csi-hostpath-sc
* Capacity: 10Mi
Create a new Pod which mounts the PersistentVolumeClaim as a volume:
* Name: web-server
* Image: nginx
* Mount path: /usr/share/nginx/html
Configure the new Pod to have ReadWriteOnce access on the volume.
Finally, using kubectl edit or kubectl patch expand the PersistentVolumeClaim to a capacity of 70Mi and record that change.
Correct Answer:
Solution:
vi pvc.yaml
storageclass pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-volume
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 10Mi
storageClassName: csi-hostpath-sc
# vi pod-pvc.yaml
apiVersion: v1
kind: Pod
metadata:
name: web-server
spec:
containers:
- name: web-server
image: nginx
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: my-volume
volumes:
- name: my-volume
persistentVolumeClaim:
claimName: pv-volume
# craete
kubectl create -f pod-pvc.yaml
#edit
kubectl edit pvc pv-volume --record
vi pvc.yaml
storageclass pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-volume
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 10Mi
storageClassName: csi-hostpath-sc
# vi pod-pvc.yaml
apiVersion: v1
kind: Pod
metadata:
name: web-server
spec:
containers:
- name: web-server
image: nginx
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: my-volume
volumes:
- name: my-volume
persistentVolumeClaim:
claimName: pv-volume
# craete
kubectl create -f pod-pvc.yaml
#edit
kubectl edit pvc pv-volume --record
Question 6
Create and configure the service front-end-service so it's accessible through NodePort and routes to the existing pod named front-end.
Correct Answer:

Question 7
Check the Image version of nginx-dev pod using jsonpath
Correct Answer:
kubect1 get po nginx-dev -o
jsonpath='{.spec.containers[].image}{"\n"}'
jsonpath='{.spec.containers[].image}{"\n"}'
Question 8
Check the image version in pod without the describe command
Correct Answer:
kubectl get po nginx -o
jsonpath='{.spec.containers[].image}{"\n"}'
jsonpath='{.spec.containers[].image}{"\n"}'
Question 9
Create a busybox pod and add "sleep 3600" command
Correct Answer:
kubectl run busybox --image=busybox --restart=Never -- /bin/sh -c
"sleep 3600"
"sleep 3600"