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:

[email protected]:~# kubectl run nginx-critical --image=nginx --dry-run=client -o yaml > nginx-critical.yaml
[email protected]:~# 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: {}
[email protected]:~# ssh node01
[email protected]:~# cd /etc/kubernetes/manifests/
[email protected]:/etc/kubernetes/manifests# ls
[email protected]:/etc/kubernetes/manifests# vi nginx-critical.yaml
[email protected]:/etc/kubernetes/manifests# exit
logout
Connection to node01 closed.
[email protected]:~# kubectl get nodes
NAME           STATUS   ROLES                  AGE     VERSION
controlplane   Ready    control-plane,master   7m24s   v1.20.0
node01         Ready    <none>                 6m39s   v1.20.0
[email protected]:~# 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>
[email protected]:~# 

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: