Certified Kubernetes Administrator (CKA) — Tips and Tricks — Part 2

Arun Ramakani
3 min readDec 3, 2019

--

Today let’s see about the static pod. There is a good weight for static pods and there is a high chance of it being a part of your exam. I did not get it correct on the first go and hence writing this blog.

Challenge 1: Recognizing the Question

The first challenge is to recognize the question as a static pod question. There may not be an explicit mention of the static pod, you will be asked to create a pod in a specific node by placing the pod definition file in a particular folder “/etc/kubernetes/manifests”. This is the folder where generally static pod definitions are kept. With these hints, you should recognize the question is all about static pods.

Challenge 2: Getting your YMAL Generator working

If you SSH into the node and tried using YAML generator as below

kubectl run — generator=run-pod/v1 nginx — image=nginx -o yaml — dry-run > nginx.yaml

It will not work as we are within a cluster on a specific node, kubeconfig on the specific node can’t connect to the cluster. The trick is to generate YAML before we SSH to the specific node, then copy the YAML into the exam notepad to use it after SSH.

Challenge 3: Make the node pick up the YAML

Once we keep the YAML definition into the folder “/etc/kubernetes/manifests” I expected it to work automatically, it did not work. The reason is static pod configuration is not done on the specific node kubelet by default. To make the static pod working, kubelet configuration file should have “staticPodPath”. Following steps will help to get the static pod up and running

  1. SSH to the node: “ssh my-node1”
  2. Gain admin privileges to the node: “sudo -i”
  3. Move to the manifest-path “cd /etc/kubernetes/manifests”
  4. Place the generated YAML into the folder “vi nginx.yaml”
  5. Find the kubelet config file path “ps -aux | grep kubelet” . This will output information on kubelet process. Locate the kubelet config file location as highlighted below

6. Edit the config file “vi /var/lib/kubelet/config.yaml” to add staticPodPath as highlighted below

7. Finally, restart the kubelet “systemctl restart kubelet”

You are all done. The static pod will be running on the specific node.

Also, visit other tips and tricks for Certified Kubernetes Administrator (CKA)

We will look into other tips and tricks in an upcoming article. Let you pass with flying colors :)

--

--

Arun Ramakani
Arun Ramakani

Written by Arun Ramakani

#ContinuousDevOps #Kubernetes #Microservices #CloudNativeApps #DevOps #Agile

Responses (2)