CKAD -Exam questions pattern.

Recently I had appeared for CKAD exam and here I am sharing some questions those I remembered plus some tips .

CKAD exam based on the curriculum

  • Core Concepts (13%)
  • Multi-Container Pods (10%)
  • Pod Design (20%)
  • State Persistence (8%)
  • Configuration (18%)
  • Observability (18%)
  • Services and Networking (13%)

Tips for exam

  • Skip the questions with weightage 2%-3% if it takes a long time , as you will waste you time to understand these kinds of questions .
  • There will be total 19 questions in the exam and you can solve any question at any time .
  • Notepad or any other software is not allowed to open apart from 2 google chrome tabs .
  • If you want to copy aliases or any other steps then copy it before hand and once you get access then paste it internal notepad of exam screen .
  • Try to solve questions using imperative commands .
  • If you want to copy aliases then , make sure you copy it first and when you get exam screen you can paste in internal notepad.
  • Useful allowed Documentation links During exam
    https://kubernetes.io/docs/
    https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-deployment-em-
  • Most useful commands :(apart below you can make aliases of commands )

— dry-run=client -o yaml
kubectl run busybox — image=busybox — restart=Never — /bin/sh -c ‘i=0; while true; do echo “$i: $(date)”; i=$((i+1)); sleep 1; done’
Kubectl create -f somefile.yaml
kubectl set image …
kubectl expose deployment …

set number relativenumber expandtab ts=2 sts=2 sw2

Sample questions from exam , there will be similar types of questions in the exam .

  1. Create pod to run command using busybox image .Command —sleep 3600; ls
kubectl run busybox --image=busybox --restart=Never --dry-run -o yaml -- bin/sh -c "sleep 3600; ls"

2. Fix image issue of deployment

 kubectl set image deploy/webapp image1=image2

3. Expose Node port service of deployment

apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: NodePort
selector:
app: MyApp
ports:
# By default and for convenience, the `targetPort` is set to the same value as the `port` field.
- port: 80
targetPort: 80
# Optional field
# By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
nodePort: 300074. Create pod and store the logs of pod to somefile

4. Create pod and store the logs of pod to somefile

kubectl run logWriter --image=logWriter
kubectl logs logWriter > \path\somefile.log

5. Find out the pod which is failing in random namespace , here you need to find out pod name and namespace which is failing and save it into given file.

Find failing pod from all namespaces 
kubectl get pod -A |grep CrashLoopBackOff

6. Update Deployment to add ServiceAccount which is already created for you .

kubectl edit deployment/mydeployment 
add service account field under pod-> spec
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
serviceAccountName: build-robot

7. Create ConfigMap — from-literals =key=value and use it as ENV varible in POD.

kubectl create configmap special-config --from-literal=special.how=very

8. Create secret — from-literals=key=value and use it in pod .

kubectl create secret generic my-secret --from-literal=key1=supersecret --from-literal=key2=topsecret

9. From Given namespace find out the pod name which is consuming top cpu

kubectl top pod -n <namespaceName>

10. Create pod which request minimum cpu of 300Mi and minimum memory of 2Gi


// add the resources section and create
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx
name: nginx
resources:
requests:
memory: "2Gi"
cpu: "300Mi"
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}

11. Create readiness probe for running pod

kubectl edit pod podname

12. Create Storage with host path , then create claim for same and also create pod to use it

Create PV using below definition 
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-hostPath
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"

kubectl create -f task-pv-volume.yaml
---------------------------------------------------------
// task-pv-claim.yaml

13. Create Job which will run every 10 second using busybox and it should complete in 10 seconds .

apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: task-cronjob
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
activeDeadlineSeconds: 10
containers:
- name: hello
image: busybox
imagePullPolicy: IfNotPresent
args:
- /bin/sh
- -c
- date; Hellow from Cronjob
restartPolicy: OnFailure

kubectl create -f cronjob.yaml

14. Create NP to allowed frontend and backend pod to communicate eachother

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: simple-policy
namespace: default
spec:
podSelector:
matchLabels:
app: frontend
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: backend-namespace
- podSelector:
matchLabels:
app: backend
ports:
- protocol: TCP
port: 6379
egress:
- to:
- namespaceSelector:
matchLabels:
name: frontend-namespace
- podSelector:
matchLabels:
app: frontend
ports:
- protocol: TCP
port: 5978