The goal of this post is to help you find the answer to the following question: am I ready for the CKA exam?
The purpose of the Certified Kubernetes Administrator (CKA) program is to provide assurance that CKAs have the skills, knowledge, and competency to perform the responsibilities of Kubernetes administrators.
Pre-requisites
To make use of the practice questions, you need to have a working Kubernetes cluster with:
- One control plane and one worker node.
- Kubernetes version that matches the CKA exam version (e.g. v1.22).
- A CNI of your choice that’s installed on the cluster.
kubelet
access to the cluster.- SSH access to the control plane.
- Access to Kubernetes documentation (https://kubernetes.io/docs/).
- No shared storage is required.
Disclaimer
I have to state the obvious here: these are not the real exam questions. Actually, I wouldn’t know because I’ve not taken the CKA exam yet. There is a small probability, mathematically speaking, that these might be the questions. Any similarity to exam questions is purely coincidental.
Solving the practice questions does not automatically indicate that you are ready to take the CKA exam because the questions here do not cover all exam objectives. Having said that, if you can’t solve the practice questions then you’re likely not ready.
CKA Practice Questions
1. Create a namespace cka. All resources should be created in this namespace.
2. Create a new Secret
named mysql-password that has the following key=value pair:
mysql_root_password
= Mysql5.6Password
3. Create a new PersistentVolume
named pv-mysql.
- Set
capacity
to 1Gi. - Set
accessMode
to ReadWriteOnce. - Set
hostPath
to /data_mysql. - Set
persistentVolumeReclaimPolicy
to Recycle. - The volume should have no
storageClassName
defined.
4. Create a new PersistentVolumeClaim
named pvc-mysql. It should request 1Gi storage, accessMode ReadWriteOnce and should not define a storageClassName
. The PVC should bound to the PV correctly.
5. Create a new StatefulSet
named mysql.
- Use container image mysql:5.6.
- The container in the pod should
runAsUser=65534
andrunAsGroup=65534
. - Mount the persistent volume pv-mysql at /var/lib/mysql.
- There should be only 1 replica running.
- Define
initContainer
named fix-permissions that uses image busybox:1.35. - The init container should
runAsUser=0
. - The init container should mount the persistent volume pv-mysql and run the following command:
["sh", "-c", "chown -R 65534:65534 /var/lib/mysql"]
.
6. Configure the stateful set mysql deployment so that the underlying container has the following environment variables set:
MYSQL_ROOT_PASSWORD
from secret mysql-password key mysql_root_password.
7. Create a new ClusterIP Service
named mysql which exposes mysql pods from the stateful set on port 3306.
8. Create a new Deployment
named wordpress.
- Use container image wordpress:4.8-apache.
- Use deployment strategy Recreate.
- There should be 3 replicas created.
- The pods should request 10m cpu and 64Mi memory.
- The
livenessProbe
should perform an HTTP GET request to the path /readme.html and port 80 every 5 seconds. - Configure
PodAntiAffinity
to ensure that the scheduler does not co-locate replicas on a single node. - Pods of this deployment should be able to run on master nodes as well, create the proper
toleration
.
9. Configure wordpress deployment so that the underlying container has the following environment variables set:
WORDPRESS_DB_PASSWORD
from secret mysql-password key mysql_root_password.WORDPRESS_DB_HOST
set to the following value: mysql.
10. Create a NodePort Service
named wordpress which exposes wordpress deployment on port 80 and connects to the containers on port 80. The port on the node should be set to 31234.
11. Create a new NetworkPolicy
named netpol-mysql. Use the app
label of pods in your policy. The policy should allow the mysql-* pods to:
- Connect to IP block 10.0.0.0/8.
- Accept ingress traffic on port 3306 from wordpres-* pods only.
12. Navigate your web browser to http://${NODE_IP_ADDRESS}:31234/ and take a moment to enjoy a brand new instance of WordPress on Kubernetes.
13. Take a backup of etcd
running on the control plane and save it on the control plane to /tmp/etcd-backup.db.
14. Delete wordpress deployment configuration from the cluster. Verify that the application is no longer accessible.
15. Restore etcd
configuration from the backup file /tmp/etcd-backup.db. Confirm that the cluster is working and that all wordpress pods are back.
Can I have the answers as well?
Of course. Answers to the practice questions can be found on GitHub here: https://github.com/lisenet/kubernetes-homelab/tree/master/cka#bonus-exercise-am-i-ready-for-the-cka-exam
Allright, I thought I was ready for the exam…
How long for you to solve these questions?
I was able to do them in under an hour before taking the exam.
This is brilliant. Can I run this on a two node cluster (one master, one worker)?
Yes, of course.
Thank you for these kicking $$$$$ practices questions
in Q5 Answer sheet: .. should we use a headless svc for the statefullset ?
i don’t know what I am missing I am getting the following error for Q5
Error from server (BadRequest): error when creating “statefulset.yaml”: StatefulSet in version “v1” cannot be handled as a StatefulSet: strict decoding error: unknown field “spec.containers”, unknown field “spec.initContainers”
———– here is my snippet——-
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
spec:
containers:
– image: mysql:5.6
name: mysql
securityContext:
runAsUser: 65534
runAsGroup: 65534
volumeMounts:
– mountPath: /var/lib/mysql
name: pv-mysql
initContainers:
– image: busybox:1.35.
name: fix-permissions
command: [‘/bin/sh’,’-c’,’chown -R 65534:65534 /var/lib/mysql’]
securityContext:
runAsUser: 0
volumeMounts:
– mountPath: /var/lib/mysql
name: pv-mysql
The error message says that you’ve got two fields that are not known:
Containers are defined under
spec.template.spec.containers
, init containers are defined underspec.template.spec.initContainers
.The CKA Practice Questions are usually similar in format to the actual CKA certification exam, with a combination of multiple-choice, true or false, and practical questions that require hands-on experience with Kubernetes. Practicing these questions can help candidates gain confidence and improve their time management skills, which is essential for passing the CKA exam.
Hi, I’m afraid there are no multiple-choice questions on the CKA exam, it’s 100% hands-on.