iTranslated by AI
Passing the CKA Exam After Just Two Months of Learning
I passed the CKA (Certified Kubernetes Administrator) exam in May 2021, and I am writing this post to share my experience.
By the way, the passing score was 66%, and my score was exactly 66%—a real nail-biter (
Exam Purpose
I started a new job in March that used Kubernetes, so I decided to take the exam as part of my studies to gain the necessary knowledge.
I began studying from a state of having absolutely no experience with Kubernetes and passed after a 2-month study period.
Exam Overview
The exam lasts 2 hours, and you pass if you achieve a score of 66%.
It is not a multiple-choice exam but a hands-on format where you must solve presented tasks by actually executing Kubernetes commands via a command line.
When I took it, Kubernetes v1.20 was used.
During the exam, you are allowed to refer to sites under the following domains. This means you don't necessarily need to memorize kubectl commands or how to write manifests.
You can also use one external display.
The exam is conducted entirely online, and you can choose the venue and date/time with a fair amount of freedom.
The venue must be a quiet, private room where no other people enter and no other voices can be heard. I took it at home.
The scope of the CKA exam is as follows:
| Domain & Competency | Weight |
|---|---|
| Cluster Architecture, Installation & Configuration | 25% |
| Services & Networking | 20% |
| Troubleshooting | 30% |
| Workloads & Scheduling | 15% |
| Storage | 10% |
As you can see, Troubleshooting has the highest weight, so focusing your preparation there is effective.
Since this is an exam for Kubernetes administrators, you need the following knowledge in addition to kubectl commands:
- kubeadm
- etcd
- CoreDNS
- systemctl
- journalctl
Please note that you cannot refer to the documentation for etcd or CoreDNS during the exam.
Exam Flow
- 15 minutes before the exam starts, the Take Exam button on the Portal site becomes active. Click it to access the exam site.
- All communication with the proctor is done via English chat. If you apply for CKA-JP (Japanese proctored version), it seems you can communicate via Japanese chat. (By the way, the exam questions themselves are in natural Japanese.)
- Basically, you only receive instructions from the proctor in the chat, so there is almost no need to speak from your side. (I only responded with "I don't have a passport" when asked if I had one.)
- You will be instructed to turn on your webcam and share your screen. If you are using an external display, you need to share both screens.
- I accidentally shared the same screen, and there was probably no way to stop sharing. (I was instructed to reload the browser.)
- You will be instructed to show the room as slowly as possible. Especially, carefully show around and under the desk. This part ended without any particular issues for me.
- You will be instructed to bring up the "Force Quit" window with
option + command + escand close all applications exceptGoogle ChromeandFinder, as well as any non-exam tabs. I hadkubernetes.ioopen in advance, but it seems even those tabs should not be opened until instructed by the proctor. - You will be asked to present an ID for identity verification. It is best to present a passport, but since I did not have one, I presented a "debit card" and a "driver's license."
- After the proctor explains the exam and provides warnings, you can start the exam. This whole process took about 20 minutes.
- A tutorial is displayed at the start of the exam, and the 2-hour exam time begins after you finish it. You can see the remaining time on a progress bar, but the detailed time is not displayed.
- When I took it, the remaining time display bugged out and I couldn't tell how much time was left lol.
- As soon as the exam time ends, it stops accepting commands.
- Results will be notified via email within 36 hours of the exam.
Study Methods
I will list the textbooks and other resources I referred to when studying for Kubernetes and CKA.
Kubernetes Complete Guide 2nd Edition
As the title "Complete Guide" suggests, you can learn about Kubernetes knowledge comprehensively. It's a good idea to read through it initially to get an overview of the whole thing, and then refer to relevant chapters in detail as you progress with your learning.
Udemy – Certified Kubernetes Administrator (CKA) with Practice Tests
This is the well-known CKA preparation course on Udemy. It covers almost the entire scope of the CKA exam.
Not only are there video lectures by the instructor, but you can also learn in a hands-on format in an environment close to the actual exam, which is very effective. It’s great because it eliminates the high hurdle of setting up an environment when learning Kubernetes from scratch.
Also, a classic tip for Udemy is that they hold 90% off sales regularly, so make sure to buy it during a sale (
kubernetes.io
This is the official Kubernetes documentation, and it is very important to have an overview of it.
This is because kubernetes.io can be referred to during the exam.
The volume of documentation is vast, so it's difficult to read everything, but you should grasp roughly which page contains what kind of information.
In particular, the Tasks page contains useful information for taking the CKA.
CKA Self-Study Course
You can concretely organize the exam scope for CKA here as well.
The content is summarized simply, so it was perfect as a knowledge check before the exam.
Exam Tips
Create bookmarks for kubernetes.io
Since you can refer to documentation during the exam, creating bookmarks for pages you referred to while studying will save you time by allowing quick access.
I imported bookmarks from the following link:
Answer easy questions first
This is a general tip for certification exams, not just the CKA. If you encounter a difficult problem that gets you stuck, skip it once and come back to answer it later.
You can flag exam questions.
There are also simple questions provided, such as creating a Pod with specified requirements or scaling a replica.
Get used to vi operations
There are many situations where you will need to edit yaml files during the exam, but the only available editors are vi or nano. It's a good idea to practice with vi if you're not usually accustomed to it.
Embarrassingly, I was at a level where I could only use mode changes and file save/exit commands (
At a minimum, the following commands will be useful:
-
dd- Delete the current line
-
u- Undo
-
/- Search forward
- e.g.
/image
-
n- Next search result
-
N- Previous search result
-
:<number>- Jump to the line specified by <number>
Set up aliases
You will frequently use the kubectl command during the exam, so setting up an alias can save you time.
Once the exam begins, type the following command:
$ alias k=kubectl
The above command is listed in the documentation cheat sheet, so you can just copy and paste it from there without having to memorize it.
Create resource templates from commands
By adding the -o yaml --dry-run=client option, you can create a manifest template from a command for most resources, which is extremely useful.
Pod
$ kubectl run nginx --image nginx -o yaml --dry-run=client > nginx.yaml
Deployment
$ kubectl create deployment nginx --image nginx -o=yaml --dry-run=client > deployment.yaml
Service
$ kubectl expose deployment nginx --port=80 --dry-run=client -o=yaml > service.yaml
explain and --help commands
explain
When you are unsure how to write a manifest, use the explain command.
kubectl explain <type>.<fieldName>[.<fieldName>]
For example, if you forget how to write the hostPath for a PersistentVolume:
$ kubectl explain pv.spec --recursive | grep -i hostpath
hostPath <Object>
--recursive is an option that shows subfields. Since the result shows <Object>, let's dig deeper to check.
$ kubectl explain pv.spec.hostPath
KIND: PersistentVolume
VERSION: v1
RESOURCE: hostPath <Object>
DESCRIPTION:
HostPath represents a directory on the host. Provisioned by a developer or
tester. This is useful for single-node development and testing only!
On-host storage is not supported in any way and WILL NOT WORK in a
multi-node cluster. More info:
https://kubernetes.io/docs/concepts/storage/volumes#hostpath
Represents a host path mapped into a pod. Host path volumes do not support
ownership management or SELinux relabeling.
FIELDS:
path <string> -required-
Path of the directory on the host. If the path is a symlink, it will follow
the link to the real path. More info:
https://kubernetes.io/docs/concepts/storage/volumes#hostpath
type <string>
Type for HostPath Volume Defaults to "" More info:
https://kubernetes.io/docs/concepts/storage/volumes#hostpath
You can see that the path field must be specified in hostPath. Now we know it should be written in the manifest as follows:
hostPath:
path: "/mnt/data"
--help
When you are unsure how to specify options when creating resources in a declarative way, use the --help command.
# pod
$ kubectl run --help
# service
$ kubectl expose --help
$ kubectl create <type> --help
Let's check how to specify the service name when creating a service.
$ kubectl expose --help
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that
resource as the selector for a new service on the specified port. A deployment or replica set will be exposed as a
service only if its selector is convertible to a selector that service supports, i.e. when the selector contains only
the matchLabels component. Note that if no port is specified via --port and the exposed resource has multiple ports, all
will be re-used by the new service. Also if no labels are specified, the new service will re-use the labels from the
resource it exposes.
Possible resources include (case insensitive):
pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs)
Examples:
# Create a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
kubectl expose rc nginx --port=80 --target-port=8000
# Create a service for a replication controller identified by type and name specified in "nginx-controller.yaml",
which serves on port 80 and connects to the containers on port 8000.
kubectl expose -f nginx-controller.yaml --port=80 --target-port=8000
# Create a service for a pod valid-pod, which serves on port 444 with the name "frontend"
kubectl expose pod valid-pod --port=444 --name=frontend
# Create a second service based on the above service, exposing the container port 8443 as port 443 with the name
"nginx-https"
kubectl expose service nginx --port=443 --target-port=8443 --name=nginx-https
# Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
kubectl expose rc streamer --port=4100 --protocol=UDP --name=video-stream
# Create a service for a replicated nginx using replica set, which serves on port 80 and connects to the containers on
port 8000.
kubectl expose rs nginx --port=80 --target-port=8000
# Create a service for an nginx deployment, which serves on port 80 and connects to the containers on port 8000.
kubectl expose deployment nginx --port=80 --target-port=8000
Options:
--allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in
the template. Only applies to golang and jsonpath output formats.
--cluster-ip='': ClusterIP to be assigned to the service. Leave empty to auto-allocate, or set to 'None' to create
a headless service.
--dry-run='none': Must be "none", "server", or "client". If client strategy, only print the object that would be
sent, without sending it. If server strategy, submit server-side request without persisting the resource.
--external-ip='': Additional external IP address (not managed by Kubernetes) to accept for the service. If this IP
is routed to a node, the service can be accessed by this IP in addition to its generated service IP.
--field-manager='kubectl-expose': Name of the manager used to track field ownership.
-f, --filename=[]: Filename, directory, or URL to files identifying the resource to expose a service
--generator='service/v2': The name of the API generator to use. There are 2 generators: 'service/v1' and
'service/v2'. The only difference between them is that service port in v1 is named 'default', while it is left unnamed
in v2. Default is 'service/v2'.
-k, --kustomize='': Process the kustomization directory. This flag can't be used together with -f or -R.
-l, --labels='': Labels to apply to the service created by this call.
--load-balancer-ip='': IP to assign to the LoadBalancer. If empty, an ephemeral IP will be created and used
(cloud-provider specific).
--name='': The name for the newly created object.
-o, --output='': Output format. One of:
json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.
--overrides='': An inline JSON override for the generated object. If this is non-empty, it is used to override the
generated object. Requires that the object supply a valid apiVersion field.
--port='': The port that the service should serve on. Copied from the resource being exposed, if unspecified
--protocol='': The network protocol for the service to be created. Default is 'TCP'.
--record=false: Record current kubectl command in the resource annotation. If set to false, do not record the
command. If set to true, record the command. If not set, default to updating the existing annotation value only if one
already exists.
-R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
--save-config=false: If true, the configuration of current object will be saved in its annotation. Otherwise, the
annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
--selector='': A label selector to use for this service. Only equality-based selector requirements are supported.
If empty (the default) infer the selector from the replication controller or replica set.)
--session-affinity='': If non-empty, set the session affinity for the service to this; legal values: 'None',
'ClientIP'
--target-port='': Name or number for the port on the container that the service should direct traffic to.
Optional.
--template='': Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
--type='': Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is 'ClusterIP'.
Usage:
kubectl expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP|SCTP] [--target-port=number-or-name]
[--name=name] [--external-ip=external-ip-of-service] [--type=type] [options]
Use "kubectl options" for a list of global command-line options (applies to all commands).
It seems the --name option is used. Let's verify it.
$ kubectl expose po nginx --name=nginx-service --port 80 --dry-run=client -o yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx-service
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx
status:
loadBalancer: {}
Clean up your room
This was the most difficult part of the exam this time.
If you take the exam at home, you need to show your entire room to the proctor using a webcam.
Conclusion
It was an extremely meaningful exam as I was able to learn the core parts of Kubernetes.
Since it is a hands-on format rather than multiple-choice, I felt it serves as solid proof of knowledge.
Discussion