CKA Practice Questions

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:

  1. One control plane and one worker node.
  2. Kubernetes version that matches the CKA exam version (e.g. v1.22).
  3. A CNI of your choice that’s installed on the cluster.
  4. kubelet access to the cluster.
  5. SSH access to the control plane.
  6. Access to Kubernetes documentation (https://kubernetes.io/docs/).
  7. 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:

  1. mysql_root_password = Mysql5.6Password

3. Create a new PersistentVolume named pv-mysql.

  1. Set capacity to 1Gi.
  2. Set accessMode to ReadWriteOnce.
  3. Set hostPath to /data_mysql.
  4. Set persistentVolumeReclaimPolicy to Recycle.
  5. 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.

  1. Use container image mysql:5.6.
  2. The container in the pod should runAsUser=65534 and runAsGroup=65534.
  3. Mount the persistent volume pv-mysql at /var/lib/mysql.
  4. There should be only 1 replica running.
  5. Define initContainer named fix-permissions that uses image busybox:1.35.
  6. The init container should runAsUser=0.
  7. 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:

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

  1. Use container image wordpress:4.8-apache.
  2. Use deployment strategy Recreate.
  3. There should be 3 replicas created.
  4. The pods should request 10m cpu and 64Mi memory.
  5. The livenessProbe should perform an HTTP GET request to the path /readme.html and port 80 every 5 seconds.
  6. Configure PodAntiAffinity to ensure that the scheduler does not co-locate replicas on a single node.
  7. 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:

  1. WORDPRESS_DB_PASSWORD from secret mysql-password key mysql_root_password.
  2. 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:

  1. Connect to IP block 10.0.0.0/8.
  2. 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

10 thoughts on “CKA Practice Questions

  1. Thank you for these kicking $$$$$ practices questions

    in Q5 Answer sheet: .. should we use a headless svc for the statefullset ?

  2. 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:

      unknown field “spec.containers”, unknown field “spec.initContainers”

      Containers are defined under spec.template.spec.containers, init containers are defined under spec.template.spec.initContainers.

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

Leave a Reply

Your email address will not be published. Required fields are marked *