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 node01ssh 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.yamlcat /var/lib/kubelet/config.yaml|grep staticPod
in this case the path it is /etc/kubernetes/manifestsapiVersion: v1
kind: Pod
metadata:
name: static-nginx
spec:
containers:
- name: nginx-container
image: nginx
Save the file and exit node01.kubectl get po
you will notice that the static pod is getting created