Kubernetes CKA sample exam question 7 with answer

Question
Create a static pod on node01 called static-nginx with image nginx and make sure that it is recreated/restarted automatically in case of any failures happening.

Answer
Get the environment status:

kubectl get nodes
as we saw from output we have 2 nodes cluster: controlplane and node01
SSH to node01:
ssh node01
Get kubelet configuration config file:
ps aux|grep kubelet
get the configuration path from --config switch - in this case it is /var/lib/kubelet/config.yaml
Get the static pods path:
cat /var/lib/kubelet/config.yaml|grep staticPod
in this case the path it is /etc/kubernetes/manifests
Go inside this folder and create a manifest for our static pod. The file path is /etc/kubernetes/manifests/1-nginx-static.yaml:
apiVersion: v1
kind: Pod
metadata:
  name: static-nginx
spec:
  containers:
  - name: nginx-container
    image: nginx
Save the file and exit node01.
Check the pods:
kubectl get po
you will notice that the static pod is getting created