Hi All, struggling to see what I am missing for MOCK EXAM 2, Question 8 I have . . .

Brad:
Hi All, struggling to see what I am missing for MOCK EXAM 2, Question 8

I have run the pod to a .yaml file

kubectl run nginx-critical --image=nginx --dry-run=client -o yaml > test.yaml

Copied the test.yaml file’s content

ssh’d to node01

ssh node01

Change Directory to following Dir

cd /etc/kubernetes/manifests

Pasted the test.yaml file contents into a new .yaml file

static-pod.yaml

Edited the kubelet conf file with the following -

vim /var/lib/kubelet/config.yaml

staticPodPath: /etc/kubernetes/manifests

Finally restarted the kubelet service

service kubelet restart

Still no static pod created under node01… - can anyone see something I am doing wrong?

seand:
lemme fire it up and see what i get.

seand:

root@controlplane:~# kubectl run nginx-critical --image=nginx --dry-run=client -o yaml > nginx-critical.yaml
root@controlplane:~# cat nginx-critical.yaml 
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx-critical
  name: nginx-critical
spec:
  containers:
  - image: nginx
    name: nginx-critical
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
root@controlplane:~# ssh node01
root@node01:~# cd /etc/kubernetes/manifests/
root@node01:/etc/kubernetes/manifests# ls
root@node01:/etc/kubernetes/manifests# vi nginx-critical.yaml
root@node01:/etc/kubernetes/manifests# exit
logout
Connection to node01 closed.
root@controlplane:~# kubectl get nodes
NAME           STATUS   ROLES                  AGE     VERSION
controlplane   Ready    control-plane,master   7m24s   v1.20.0
node01         Ready    <none>                 6m39s   v1.20.0
root@controlplane:~# kubectl get po -owide
NAME                    READY   STATUS    RESTARTS   AGE   IP            NODE     NOMINATED NODE   READINESS GATES
nginx-critical-node01   1/1     Running   0          26s   10.50.192.1   node01   <none>           <none>
root@controlplane:~# 

seand:

seand:
maybe you need to restart the session? is your node01 in ready state? not sure what would cause your issue. what you wrote looks right to me.

Brad:
Thanks Sean for your response, I’ve just tested again and all seems to be well, although I noticed that you did not include the following steps in your process -

vim /var/lib/kubelet/config.yaml

staticPodPath: /etc/kubernetes/manifests

service kubelet restart

Are these steps not required then to create a static pod other than the master node?

seand:
were you just checking to see if the staticpodpath was set to /etc/kubernetes/mainfests or were you adding that to your kubelet config file?

edit: hit enter too soon

it’s best to see what is set for the staticpath, sure. so first you see where kubelet conf lives. it can be something other than default.

$ ps aux | grep kubelet
root       785  1.8  5.3 1866888 109340 ?      Ssl  Jan25  22:56 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --network-plugin=cni --pod-infra-container-image=<http://k8s.gcr.io/pause:3.4.1|k8s.gcr.io/pause:3.4.1>

We can see --config is indeed /var/lib/kubelet/config.yaml

So we then check to see what the staticpath is:

$ sudo cat /var/lib/kubelet/config.yaml | grep -i static
staticPodPath: /etc/kubernetes/manifests

Since it’s setup for us, there is nothing to do. If you do have to alter it, then make sure you add it and then restart kubelet as you did for the change to take effect.
I did not do what you are asking since I assumed it was setup correctly since the directory existed. If the directory was not present, I would have created it and tossed the .yaml file in there for nginx. If the pod did not start up, I would have checked to see if the static path was set somewhere else or simply not present in the kubelet config file. or perhaps there was another issue with kubelet…who knows.

seand:
I just ran through the mock exams again (practicing for the cert test) and noticed that I had to set the staticpoddir this time through. so yeah, definitely add that to the config.yaml and restart kubelet service :slightly_smiling_face:

Hello, i have the same issue. i have changed static pod path to somewhere else and created static pod under it. but it did not take effect even after kubelete service was restartad