CKAD Study & Exam Tips
https://community.cncf.io/manly
Agenda
2
https://community.cncf.io/manly
10 mins
10 mins
10 mins
Exam Tips
Study Tips
Practical Examples
Q&A Session / Discussion
15 mins
Special thanks
3
https://community.cncf.io/manly
https://kubernetes.io/docs/contribute/participate
SIG Docs
slack.cncf.io
slack.k8s.io
Exam Tips - Why sit the exam
4
https://community.cncf.io/manly
As one of the highest velocity projects in the history of open source, Kubernetes use is exploding. The Cloud Native Computing Foundation is committed to growing the community of Kubernetes-knowledgeable application developers, thereby enabling continued growth across the broad set of organizations using the technology.
Certification is a key step in that process, allowing certified application developers to quickly establish their credibility and value in the job market, and also allowing companies to more quickly hire high-quality teams to support their growth.
Exam Tips - Exam Curriculum
5
https://community.cncf.io/manly
CKAD Certificate
6
https://community.cncf.io/manly
Exam Tips
7
https://community.cncf.io/manly
Exam Tips - Booking your exam
8
https://community.cncf.io/manly
To book goto: https://www.cncf.io/certification/ckad
Exam Tips - Discount Codes
9
https://community.cncf.io/manly
https://events.linuxfoundation.org/kubecon-cloudnativecon-europe/register
Exam Day
10
https://community.cncf.io/manly
Exam
Questions
Exam Tips
11
https://community.cncf.io/manly
Exam Tips
12
https://community.cncf.io/manly
Exam Tips - Naming YAML files
13
https://community.cncf.io/manly
When generating YAML files, name them with the question number
Example
1.yaml
1-svc.yaml
kubectl run example bradmccoydev/test:latest -o yaml > 1.yaml
cp 1.yaml 1a.yaml (backup if required)
kubectl create -f 1.yaml
Exam Tips - alias k=kubectl
14
https://community.cncf.io/manly
alias k=kubectl
Use this so you don’t have to keep typing kubectl all the time
Eg.
alias k=kubectl
k run nginx --image=nginx
Exam Tips
15
https://community.cncf.io/manly
Make sure you are in the right cluster, and the right namespace as specified in the question, to avoid deploying to the wrong namespace when using YAML to create resources specify it in the metadata in case you forget.
Exam Tips - kubectl api-resources
16
https://community.cncf.io/manly
kubectl api-resources to get names/short names eg. kubectl get svc
Exam Tips - Reverse Search (Ctrl + r)
17
https://community.cncf.io/manly
Exam Tips - Watch command
18
https://community.cncf.io/manly
Make use of the watch command when checking if deployments worked etc it will execute the command every 2 seconds until you ctrl + c eg watch kubectl get pods
Exam Tips - kubectl -h command
19
https://community.cncf.io/manly
Use the -h for help! kubectl run -h gives some hints if you forgot imperative commands under pressure.
Practice the -h command on other options such as kubectl create deploy -h etc
Study Tips
20
https://community.cncf.io/manly
Study Tips - Courses
21
https://community.cncf.io/manly
walidshaari/Kubernetes-Certified-Administrator.git
Study Tips - Use bookmarks!
22
https://community.cncf.io/manly
In the exam you are allowed to use bookmarks for the documentation so as you study and learn add bookmarks to the page in kubernetes docs.
When you do your practice tests and practical work, refer to the bookmarks and not your notes, this will help you be fast for exam day.
Study Tips - Use bookmarks!
23
https://community.cncf.io/manly
Study Tips - kubectl Reference Docs
24
https://community.cncf.io/manly
Study Tips - VIM
25
https://community.cncf.io/manly
If you don’t know VIM editor learn it. You can get away with just knowing nano, by setting KUBE_EDITOR=”nano” but when you need to edit deployments etc it will default to VIM so you don’t want to risk being stuck. If you don't know VIM you are not ready for you exam.
VIM Cheat Sheet: vim.rtorr.com
Study Tips - VIM
26
https://community.cncf.io/manly
There are two modes, for writing/deleting text press i, then press esc for edit mode
To exit without saving press esc and type :q!
To exit with saving press esc and type :wq!
To delete a line type dd
To delete more than one line type 5dd (substitute 5 for the number you want to delete)
To Goto line 5 type 5gg (substitute 5 for the number you want to goto)
To Jump to the end of the line type $
To search for a word eg image press esc then type /image and press enter
To show line numbers press esc and then type :set number
Study Tips - Basic linux commands
27
https://community.cncf.io/manly
If you are a developer doing this course and you are not used to linux, it is worth learning basic linux commands.
Command | Description | Example |
cd | Used to go into or out of a folder | cd myfolder (cd .. to go back) |
ls | List files/folders in a directory | ls (ls myfolder to list contents of myfolder) |
grep | Searches for text | cat 1.yaml | grep image |
cat | Read a file on the console | cat deployment.yaml |
cp | Copy a file | cp 1.yaml 1a.yaml |
mv | Move a file | mv 1.yaml backup/1.yaml |
mkdir | Make a directory | mkdir test |
rm | Removes a file or folder | rm 1.yaml (rm -R myfolder for directory) |
vi | Go into vi editor | vi deployment.yaml |
Practical Examples
28
https://community.cncf.io/manly
Practical Examples
29
https://community.cncf.io/manly
Practical Examples - General
30
https://community.cncf.io/manly
Command | Description |
kubectl get pods --show-labels | Show labels for pods |
Kubectl get pods -l app=postgres | List pods that have the label app=postgres |
kubectl get pods -A | Show pods in all namespaces |
kubectl get all -n dev | Show all (most) things in the namespace dev |
kubectl api-resources | Get names/short names for resources |
kubectl run -h | Get help for kubectl |
alias k=kubectl | Sets k as the alias for kubectl |
Practical Examples - Core Concepts
31
https://community.cncf.io/manly
kubectl run -h
kubectl run nginx --image nginx --dry-run=client -o yaml > 1.yaml
kubectl run hazelcast --image=hazelcast/hazelcast --port=5701
kubectl run hazelcast --image=hazelcast/hazelcast --env="app=hazelcast,env=prod"
kubectl run hazelcast --image=hazelcast/hazelcast --labels="app=hazelcast,env=prod"
kubectl run hazelcast --image=hazelcast/hazelcast --command ‘sleep 3600’
kubectl run hazelcast --image=hazelcast/hazelcast --requests=’cpu=100m,memory=256Mi’
kubectl run hazelcast --image=hazelcast/hazelcast --limits=’cpu=200m,memory=512Mi’
Practical Examples - Configuration
32
https://community.cncf.io/manly
# Config Maps (cm for short)
kubectl create configmap myconfig --from-literal=username=brad
kubectl get configmap myconfig -o yaml
kubectl run test-pod --image busybox --dry-run=client -o yaml > 1.yaml
kubectl create -f 1.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
containers:
- name: test-container
image: busybox
env:
# Define the environment variable
- name: USERNAME
valueFrom:
configMapKeyRef:
# The ConfigMap containing the value you want to assign to USERNAME
name: myconfig
# Specify the key associated with the value
key: username
https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-configmap-em-
Practical Examples - Configuration
33
https://community.cncf.io/manly
# Secrets
kubectl create secret generic mysecret --from-literal=password=123
kubectl get secret mysecret -o yaml
kubectl run test-pod --image busybox --dry-run=client -o yaml > 1.yaml
kubectl create -f 1.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
containers:
- name: test-container
image: busybox
env:
# Define the environment variable
- name: PASSWORD
valueFrom:
secretKeyRef:
name: mysecret
key: password
https://kubernetes.io/docs/concepts/configuration/secret/
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-secret-generic-em-
Practical Examples - Configuration
34
https://community.cncf.io/manly
# Service account
kubectl create serviceaccount my-service-account
kubectl get serviceaccount my-service-account
kubectl run test-pod --image busybox --serviceaccount='my-service-account'
https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-serviceaccount-em-
Practical Examples - Observability
35
https://community.cncf.io/manly
# Get logs from pod
kubectl logs my-pod
# Get logs from pods with the name label myLabel
kubectl logs -l name=myLabel
# Output logs to console
kubectl exec my-pod -c my-container -- cat /var/log.txt (multi container)
# Go into the pod to look for the logs
kubectl -n your-namespace exec -it pod/your-pod -- /bin/sh
# Kubectl cheatsheet
https://kubernetes.io/docs/reference/kubectl/cheatsheet
Practical Examples - Observability
36
https://community.cncf.io/manly
kubectl top node
kubectl top pod
Practical Examples - Pod Design
37
https://community.cncf.io/manly
kubectl create deployment my-dep --image=nginx --replicas=3 --port=5701
Practical Examples - Pod Design
38
https://community.cncf.io/manly
# Rolling updates, and rollbacks
kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1 --record
kubectl rollout status deployment/nginx-deployment
kubectl rollout undo deployment/nginx-deployment
# Jobs
kubectl create job my-job --image=busybox -- date
https://kubernetes.io/docs/concepts/workloads/controllers/job
# Cronjobs
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs
Practical Examples - Services and Networking
39
https://community.cncf.io/manly
# Services
kubectl create service clusterip my-cs --tcp=5678:8080
kubectl create service nodeport my-ns --tcp=5678:8080
Kubectl expose deployment nginx --port=80 --target-port=8000 (--type=ClusterIP,NodePort)
# Network policies
https://kubernetes.io/docs/concepts/services-networking/network-policies/
Practical Examples - State Persistence
40
https://community.cncf.io/manly
# Host path example
https://kubernetes.io/docs/concepts/storage/volumes
If you can’t find something in the documentation remember you can use the kubectl explain command
kubectl explain pv --recursive
kubectl explain pod --recursive
apiVersion: v1
kind: Pod
metadata:
name: test-pd
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory
Practical Examples - State Persistence
41
https://community.cncf.io/manly
We will do a separate talk on this as there is alot to cover
https://kubernetes.io/docs/tasks/configure-pod-container/configure-volume-storage
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage
Conclusion
42
https://community.cncf.io/manly
Don’t be afraid to fail. I failed my first attempt but it gave me a good opportunity to see where I needed to improve, and passed on my free retake with a high score.
Learn the basics first, you will save time in the long run, learn basic linux, learn VIM, learn kubectl well.
If you are having trouble getting a test environment to practice with maybe your cpu, ram on your computer can’t run Kubernetes or can’t afford it, reach out to me and I will see what I can do.
Have fun studying, and remember there is a wonderful community out there to help you!
Important Links - https://github.com/bradmccoydev/cncf-community-manly
43
https://community.cncf.io/manly
https://kubernetes.io/docs/contribute/participate
slack.cncf.io
slack.k8s.io
https://www.cncf.io/certification/ckad
https://events.linuxfoundation.org/kubecon-cloudnativecon-europe/register
vim.rtorr.com
https://itnext.io/kubernetes-journey-cka-ckad-exam-tips-ff73e4672833
https://kubernetes.io/docs/home
Links will be added to: https://github.com/bradmccoydev/cncf-community-manly
Thank You
44
Join us: https://community.cncf.io/manly
CC-BY License
45
https://community.cncf.io/manly
This presentation is licensed under a Creative Commons Attribution 4.0 International License.
See https://creativecommons.org/licenses/by/4.0/ for more details.