General Tips & Practice Setup
Material that doesn’t belong to a single scored domain: exam-day speed tips, editor shortcuts, and how to spin up a cheap practice cluster.
Important vi Tips
- ‘dG’ - Deletes contents from cursor to end of file. This is very useful when editing YAML files.
- ‘ZZ’ - Save and exit quickly.
kubectl Tips
To set nano as your editor for ‘kubectl edit’
export KUBE_EDITOR="nano"
Exam Speed Tips
This section contains some general pointers to help pass the exam.
The exam is primarily about speed. With that in mind, the best way to approach the moderate to complex questions is to generate the initial YAML via the dry run flag. Then, edit the file with either vi or nano, and then create the required resource. The steps are outlined below.
$ kubectl run nginx --image=nginx --restart=Never --dry-run -o yaml > mypod.yaml
$ nano mypod.yaml
$ kubectl create -f mypod.yaml
pod "nginx" created
There you go. If you’re not satisfied with the results. Delete the resource, re-edit the declaritive yaml file, and redo.
$ kubectl delete -f mypod.yaml
pod "nginx" deleted
$ nano mypod.yaml
$ kubectl create -f mypod.yaml
pod "nginx" created
Overview
The exam is 100% hands on using the innovative exams (www.examslocal.com) product. The CKAD exam requires an excellent understanding of K8s along with how to efficiently use kubectl to accomplish various tasks on Kubernetes. I’m sure they use this exam approach as it pretty much precludes any form of cheating. You either know the material and can very quickly implement it or not.
You will be given a list of ‘tasks’ to accomplish on one of four kubernetes clusters (these are described in the official exam tips above). The exam is ‘open book’ but only with the content available at kubernetes.io. You will have one tab for the exam content and one additional tab for kubernetes.io. However, don’t expect that you can just research questions during the exam, as there will be very little time for ‘learning’ a specific k8s concept at exam time. It’s there to help with YAML syntax detail only, IMO.
I think the best approach is to fork this repo as a starting point for your studies, and then use the markdown checklist to ensure you cover all of the expected material, etc.
Historical (v1.0 curriculum) progress checklist
The old CKAD curriculum (pre-2024 reorg) used a different domain breakdown than the current one reflected in examinfo.yaml. Kept here for historical reference:
- Core Concepts - 13%
- API Primitives
- Create and Configure Basic Pods
- Configuration - 18%
- Understand ConfigMaps
- Understand SecurityContexts
- Define App Resource Requirements
- Create and Consume Secrets
- Understand Service Accounts
- Multi-Container Pods - 10%
- Design Patterns: Ambassador, Adapter, Sidecar
- - Sidecar Pattern
- - Init Containers
- Design Patterns: Ambassador, Adapter, Sidecar
- Pod Design - 20%
- Using Labels, Selectors, and Annotations
- Understand Deployments and Rolling Updates
- Understand Deployment Rollbacks
- Understand Jobs and CronJobs
- - State Persistence - 8%
- - Understand PVCs for Storage
- Observability - 18%
- Liveness and Readiness Probes
- Understand Container Logging
- Understand Monitoring Application in Kubernetes
- Understand Debugging in Kubernetes
- Services and Networking - 13%
- Understand Services
- Basic Network Policies
Where to Practice
This particular items was difficult for me as I didn’t have a (current) k8s cluster to use at work. As I was initially studying for the CKA which requires more cluster-level work, I tried many, many different approaches for an inexpensive k8s environment. built many clusters using K8s The Hard way on gcloud (and AWS), built a raspberry pi cluster I could carry to work, and tried using kubeadm / kops on gcloud and aws.
In my opinion, and all that is required to pass this test, is to just setup a gcloud account, and use a two-node GKE cluster for studying. Heck, you can even use the very nice google cloud shell and not even leave your browser.
gcloud command line (SDK) documentation
Here are commands used to create a two-node cluster for studying. I keep these here just so I can fire up and destroy a cluster for a few hours each day for study. Notice that you can tailor the cluster version to match the k8s version for the exam.
gcloud config set compute/zone us-central1-a
gcloud config set compute/region us-central1
gcloud container clusters create my-cluster --cluster-version=1.15.8-gke.2 --image-type=ubuntu --num-nodes=2
The result:
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
my-cluster us-central1-a v1.15.8-gke.2 35.232.253.6 n1-standard-1 v1.15.8-gke.2 2 RUNNING
cloudshell:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
gke-my-cluster-default-pool-5f731fab-9d6n Ready <none> 44s v1.15.8-gke.2
gke-my-cluster-default-pool-5f731fab-llrb Ready <none> 41s v1.15.8-gke.2
Setting kubectl Credentials
If using the cloud shell, you’ll sometimes need to authorize kubectl to connect to your cluster instance.
gcloud container clusters get-credentials my-cluster
Deleting Your Cluster
No need to keep the cluster around when not studying, so:
gcloud container clusters delete my-cluster
To Get Current GKE Kubernetes Versions
gcloud container get-server-config
Miscellaneous Tips and Tricks
Extracting yaml from running resource
Use the –export and -o yaml flags to export the basic yaml from an existing resource:
kubectl get deploy busybox --export -o yaml > exported.yaml
The –dry-run flag
The –dry-run flag can be used with the kubectl run and create commands. It provides a nice template to start your declarative yaml config files. Below is an example for creating a basic secret yaml.
kubectl create secret generic my-secret --from-literal=foo=bar -o yaml --dry-run > my-secret.yaml
The –from-literal flag
As shown above, the –from-literal flag is useful for things like config maps and secrets for the basic cases.
apiVersion: v1
data:
foo: YmFy
kind: Secret
metadata:
creationTimestamp: null
name: my-secret