Site icon UnixArena

Kubernetes – CKA sample exam questions

CKA

CKA

There is no doubt about the fact that the adoption of Kubernetes is expected to grow exceptionally in upcoming years. Kubernetes Job search has been vastly increased by 200% in job portals. The Certified Kubernetes Administrator (CKA) program was created by the Cloud Native Computing Foundation (CNCF), in collaboration with The Linux Foundation. CKA exams are designed to give in online anytime and anywhere. An online proctor will be watching you throughout the exam. CKA exams are not multiple-choice exams like other cloud certification exams. It’s an online performance-based exam and you must know how technology works. It’s an open book exam where you can refer to the Kubernetes documents throughout the exam.

I would like to share a few sample questions to practice for the CKA exam.

  1. Create nginx prod and list the pod with different levels of verbosity.
[root@kmaster ~]# kubectl run nginx --image=nginx --restart=Never --port=80 
[root@kmaster ~]#

List the pod with different verbosity.

[root@kmaster ~]# kubectl get po nginx --v=6
I0629 03:06:25.915631    9229 loader.go:372] Config loaded from file:  /root/.kube/config
I0629 03:06:27.773296    9229 round_trippers.go:454] GET https://kubecls-dns-f85bdfdb.hcp.westus2.azmk8s.io:443/api/v1/namespaces/default/pods/nginx 200 OK in 1822 milliseconds
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          14m
[root@kmaster ~]#
[root@kmaster ~]# kubectl get po nginx --v=7
I0629 03:06:29.985304    9234 loader.go:372] Config loaded from file:  /root/.kube/config
I0629 03:06:30.013225    9234 round_trippers.go:432] GET https://kubecls-dns-f85bdfdb.hcp.westus2.azmk8s.io:443/api/v1/namespaces/default/pods/nginx
I0629 03:06:30.013276    9234 round_trippers.go:438] Request Headers:
I0629 03:06:30.013303    9234 round_trippers.go:442]     Authorization: Bearer <masked>
I0629 03:06:30.013323    9234 round_trippers.go:442]     Accept: application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io,application/json
I0629 03:06:30.013340    9234 round_trippers.go:442]     User-Agent: kubectl/v1.21.2 (linux/amd64) kubernetes/092fbfb
 [root@kmaster ~]# 

2. Create a new “nginx” pod with label env=sandbox in prod namespace.

 
 #Create name space prod
 [root@kmaster ~]# kubectl create ns prod
 namespace/prod created
 
 #Create deployment file using dry-run
 [root@kmaster ~]# kubectl run nginx --image=nginx --restart=Never --labels=env=sandbox  --namespace=prod--dry-run=client -o yaml > nginx.yaml

 #Create pod using YAML.
 [root@kmaster ~]# kubectl apply -f nginx.yaml
 pod/nginx created
 [root@kmaster ~]#

#Validate your deployment
[root@kmaster ~]# kubectl get po -n prod
NAME    READY   STATUS    RESTARTS   AGE
 nginx   1/1     Running   0          8m42s
 [root@kmaster ~]#
 [root@kmaster ~]# kubectl describe po nginx -n prod
 Name:         nginx
 Namespace:    prod
 Priority:     0
 Node:         aks-agentpool-31544307-vmss000001/10.240.0.115
 Start Time:   Tue, 29 Jun 2021 03:03:47 -0400
 Labels:       env=sandbox
 Annotations:  
 Status:       Running
 IP:           10.240.0.195
 IPs:
   IP:  10.240.0.195

3. Create a busybox pod and add the “sleep 3600” command.

[root@kmaster ~]# kubectl run busybox --image=busybox --restart=Never -- /bin/sh -c "sleep 3600" pod/busybox created

# Validate the pod status
[root@kmaster ~]# kubectl get po busybox
 NAME      READY   STATUS    RESTARTS   AGE
 busybox   1/1     Running   0          9s
 [root@kmaster ~]#
 busybox   1/1     Running   0          82s
 [root@kmaster ~]# kubectl describe  po busybox |more
 Name:         busybox
 Namespace:    default
 Priority:     0
 Node:         aks-agentpool-31544307-vmss000000/10.240.0.4
 Start Time:   Tue, 29 Jun 2021 03:17:53 -0400
 Labels:       run=busybox
 Annotations:  
 Status:       Running
 IP:           10.240.0.78
 IPs:
   IP:  10.240.0.78

4. Create a job named “hello-job” with the image “busybox” which echo’s “Hello I’m running job”.

Create YAML file for job
 [root@kmaster ~]# kubectl create job hello-job --image=busybox --dry-run=client -o yaml -- echo "Hello I'm running job" > hello-job.yaml
 Create job
 [root@kmaster ~]# kubectl create -f hello-job.yaml
 job.batch/hello-job created
 List the jobs
 [root@kmaster ~]# kubectl get jobs
 NAME        COMPLETIONS   DURATION   AGE
 hello-job   1/1           3s         2m58s
 [root@kmaster ~]#
 List the pods
 [root@kmaster ~]# kubectl get po
 NAME              READY   STATUS      RESTARTS   AGE
 busybox           1/1     Running     0          16m
 hello-job-x7kcj   0/1     Completed   0          16s
 nginx             1/1     Running     0          42m
 Check the logs
 [root@kmaster ~]# kubectl logs hello-job-x7kcj
 Hello I'm running job
 [root@kmaster ~]#

I will keep posting the sample exam questions of CKA (Certified Kubernetes Administrator) exam.

Exit mobile version