CNCF CKA / CKAD Hints & Tips

Use kubectl alias & export commands
Assuming your an average-accuracy typer like me, you’ll be pleasantly surprised how much time is saved using aliases & command segment exports, resulting in less stress & frustration too !

Some punters have extensive lists of command & editor configuration pre-sets to apply upon entering the exam session – I try to be pragmatic, so start with this minimal set…

alias k=kubectl
export dry=" --dry-run=client -o yaml "
export now=" --force --grace-period 0 "

Dry Run Example

k create deploy nginx –image=nginx $dry

Force Delete Example

k delete po pod1 $now

 

kubectl <command> --help

=> kubectl <command> –help
Random example
=>kubectl config view –help

Display merged kubeconfig settings or a specified kubeconfig file.

You can use –output jsonpath={…} to extract specific values using a jsonpath
expression.

Examples:
# Show merged kubeconfig settings
kubectl config view

When you cant quite remember a complete command & options combination, just type the basic command and suffix with –help

–help is immensely useful to display the details of commands alongside –option descriptions and usage information.

–help information is presented in the following format.

Examples:
# Shows examples

Options:
–myoption    # meaning

Usage:
kubectl <command> [flags] [options]

 

 

Understand basic DNS for calling K8s Services

Each new K8s Service has an automatically assigned virtual IP address, and associated DNS name which can be registered in following generalised format.

<service-name>.<ns>.<service>.<domain...>

Say we have a new Service jess-lookup in the research namespace…

From all other K8s namespaces, we must explicitly call this service using its FQDN (Fully Qualified Domain Name);

jess-lookup.research.svc.cluster.local

However, to call this Service within the same K8s namespace, here research, we can simply refer to the service-name, also called the service short name (which K8s internally autocompletes to the FQDN);

jess-lookup 
Love the VI Editor

Exam requires basic proficiency in exam-session default vi editor.

Learn & practice editing manifest files using kubectl edit until you are comfortable with it. Use the commonly available online CKAD / CKA  / CKS practice exam environments to bring up your vi skills …

Read CNCF Hints & Tips
Use Command History

Rather than attempt to type every command…

  • use the UP Arrow Key to quickly step back through your Command History.
  • then can use the DOWN Arrow Key to move forward from your current position in the Command History.

Find the same or similar command, use the LEFT & RIGHT Arrow Keys and backspace to tweak the command to what you need & hit Enter.

Practice this & you will find use of Command History can be much faster than simply re-typing everything…

Carefully Check & Set K8s Cluster Context on EVERY Q

Nearly every Exam Q requires you to explicitly set the cluster context using the following command below.

This is typically the VERY FIRST THING you must do when tackling a Question. If you get this wrong you may complete a perfectly valid answer in an incorrect K8s Context & therefore score 0 marks.

kubectl config use-context <Q-provided-context-name>

Example 

kubectl config use-context k8sdsn

Utilities & Tools for checking Service connectivity

A number of Q scenarios require checks & troubleshooting on Ingress & Service connectivity. Be familiar with use of the following commands.

ssh <nodename> or ssh <node-IP>
sudo -i
nc -v -z -w 5 service-name 80
curl -m 5 manager-api.mars:4444
curl -m 5 192.0.3.43:80
wget -O- api:2222
netstat -pand | grep LISTEN
...
A generic CKAD RunBook on how to scope each Q

CKAD Runbook on best approach to scope how to tackle each Q – Possible Techniques
1. Imperative First: kubectl create <resource> -h or –help
2. Check K8s Resources: – kubectl api-resources & api-versions & options
3. Try to use ephemeral pods: kubectl run/ exec -it –rm <resource> …
4. Use KAS to generate manifests: kubectl get <resource> <name> -o yaml dry-run=client & vi apply or replace –force
5. Check Commands: kubernetes.io/docs/reference/kubectl
6. Check API details: kubectl explain <Kind>.<path> e.g. pod.spec.containers
7. Set Context for each Q: kubectl config set-context –current –namespace=NAMESPACE